Skip to main content

Math.trunc()

语法​

trunc(x: number): number;

描述​

用于将数字的小数部分去掉,只保留整数部分。

示例​

Math.trunc(Math.PI); // 3
Math.trunc(0.1 + 0.2); // 0
Math.trunc(Infinity); // Infinity