在平常开发中可能有不少不被重视但有关系着基础的知识,下面咱们就来看看这几道题吧数组
题1prototype
["1","2","3"].map(parseInt)
输出结果为 [1NaN,NaN]code
由于parseInt须要2个参数(val,radix)单map传了3个(element,index,array)对象
题2element
[typeof null, null instanceof Object]
输出结果为['object',false]开发
typeof 对原生非可调用对象始终返回 'object'console
题3基础
[ [3,2,1].reduce(Math.pow), [].reduce(Math.pow)] ]
想一想这题的输出结果为是什么勒? 是[9,0]吗?object
固然不对,根据规范,在一个空数组上应用reduce会抛初始化错误的异常 TypeErrormap
题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 又不等同