function Example(name){ return this.name = name; } console.log([0,"0",[],{},null].map(i => typeof new Example(i).name));
我运行结果为:["number", "string", "undefined", "undefined", "object"] 为什么会有undefined的呐?
收起
因为空数组中没有值,对象中没有属性和值,故读取数组中或对象中没有的属性值,会返回一个undefined
报告相同问题?