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既是数字又是字符串呢
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既是数字又是字符串呢
//toFixed(),返回的就是number Object 的字符串显示,判断其类型使用Object.prototype.toString.call(12.12331.toFixed(3))
//"[object String]" 其结果就是字符串
//isNaN判断为true
//y+1,将number 1 转换成string,最后就是字符串相加
13 回答12.6k 阅读
7 回答1.7k 阅读
3 回答1k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
2 回答1.8k 阅读
2 回答1k 阅读✓ 已解决
使用isNaN会使用Number进行隐式转换