在一样平常开辟中可能有许多不被注重但有关系著基本的学问,下面我们就来看看这几道题吧
题1
["1","2","3"].map(parseInt)
输出效果为 [1NaN,NaN]
由于parseInt须要2个参数(val,radix)单map传了3个(element,index,array)
题2
[typeof null, null instanceof Object]
输出效果为[‘object’,false]
typeof 对原生非可挪用对象一直返回 ‘object’
题3
[ [3,2,1].reduce(Math.pow), [].reduce(Math.pow)] ]
想一想这题的输出效果为是什么勒? 是[9,0]吗?
固然不对,依据范例,在一个空数组上运用reduce会抛初始化毛病的非常 TypeError
题4
Array.isArray( Array.prototype )
输出效果为 true
Array.prototype 是一个 Array
题5
var a = [0];
if ([0]) {
console.log(a == true);
} else {
console.log("wut");
}
输出false
[0] 被认为是真的,但跟 true 又不同等