mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
cache hasOwnProperty
This commit is contained in:
@@ -391,10 +391,11 @@
|
||||
/* ------------------------- Object Functions: ---------------------------- */
|
||||
|
||||
// Retrieve the names of an object's properties.
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
_.keys = function(obj) {
|
||||
if(_.isArray(obj)) return _.range(0, obj.length);
|
||||
var keys = [];
|
||||
for (var key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) keys.push(key);
|
||||
for (var key in obj) if (hasOwnProperty.call(obj, key)) keys.push(key);
|
||||
return keys;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user