toString(2)和toFixed(2)方法的讲解

<script>
var num = 3;
var num1 = 3.33;
/*
toString()方法可以根据所传递的参数把数值转换为对应进制的数字字符串。参数范围为 2~36 之间的任意整数。
toFixed(2)方法可以把Number 四舍五入为指定小数位数的数字
*/
console.log(num.toString(2));
console.log(num.toFixed(2));
console.log(num1.toFixed(4));
</script>
posted @ 2019-12-19 13:22  倔强的代码人  阅读(3914)  评论(0编辑  收藏  举报