<分区>
来自 underscore.js 的测试对象片段
_.isObject = function(obj) {
return obj === Object(obj);
};
这到底是做什么让它检查类型的?
jsperf 显示这比使用传统检查更快,这就是使用它的原因。
<分区>
来自 underscore.js 的测试对象片段
_.isObject = function(obj) {
return obj === Object(obj);
};
这到底是做什么让它检查类型的?
jsperf 显示这比使用传统检查更快,这就是使用它的原因。
最佳答案
The Object constructor creates an object wrapper for the given value. If the value is null or undefined, it will create and return an empty object, otherwise, it will return an object of a type that corresponds to the given value.
关于javascript - 性能 - Object(obj) 做什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15955520/