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