我知道:
console.log({}.length);
> undefined
console.log([].length);
> 0
console.log([] + {});
> [object Object]但是,为什么([] + {})是[object Object]
console.log(([] + {}).length);
> 15为什么.我搞不懂
发布于 2015-10-20 11:23:26
我的控制台给了我这个:
typeof []
"object"
typeof {}
"object"
typeof [] + {}
"object[object Object]"
typeof ([] + {})
"string"上一个console.log的长度是因为它是一个字符串。
https://stackoverflow.com/questions/33235269
复制相似问题