JavaScript中的Math.trunc()函数
trunc()Math对象的函数接受一个数字并返回其整数点(不包括小数部分)。如果给定的数字本身是整数,则此函数返回相同的值。
语法
其语法如下
Math.trunc();
示例
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var result = Math.trunc(58.745);
document.write("Integral part of the given number: "+result);
</script>
</body>
</html>输出结果
Integral part of the given number: 58
热门推荐
2 合字的祝福语简短
10 新娘上头祝福语大全简短
11 中秋祝福语送朋友简短
12 俄语祝福语贺卡文案简短
13 周年蛋糕祝福语简短英语
14 祝妹妹毕业祝福语简短
15 亲姐姐祝福语简短英文
16 浪漫的生日祝福语简短
17 妈妈祝福语简短16字
18 给婴儿祝福语简短的话