面试题
https://segmentfault.com/a/1190000015383749
1.
console.log(typeof []) //"object" console.log(typeof typeof []) //=》typeof "object" //"string"
因为typeof返回结果都是字符串
2.
<script type="text/javascript">
var num = parseInt('width:35.5px');
if (num == 35.5) {
alert(0)
} else if (num == 35) {
alert(1)
} else if (num == NaN) {
alert(2)
} else if (typeof num == 'number') {
alert(3)
} else {
alert(4)
}
console.log(typeof num)//number
console.log(typeof num == 'number')//true
//3
</script>

浙公网安备 33010602011771号