var arr = [119.657958,29.108071];
function c(){
var x = ((Math.random()-0.5)/500).toFixed(6);
console.log(x);
return x;
}
let y = c();
console.log(isNaN(y));
console.log(typeof y);
console.log(y+1);
结果为

为什么y既是数字又是字符串呢
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
使用isNaN会使用Number进行隐式转换
toFixed() 的返回值是string类型的
问题大家都答得差不多啦, 我就是想问楼主这个isNaN()是怎么做到返回true的?
toFixed()返回值是string类型的,输入的值是number类型的