mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Fixing #95 ... Maloptimization of _.keys for sparse arrays.
This commit is contained in:
@@ -501,7 +501,6 @@
|
|||||||
// Retrieve the names of an object's properties.
|
// Retrieve the names of an object's properties.
|
||||||
// Delegates to **ECMAScript 5**'s native `Object.keys`
|
// Delegates to **ECMAScript 5**'s native `Object.keys`
|
||||||
_.keys = nativeKeys || function(obj) {
|
_.keys = nativeKeys || function(obj) {
|
||||||
if (_.isArray(obj)) return _.range(0, obj.length);
|
|
||||||
var keys = [];
|
var keys = [];
|
||||||
for (var key in obj) if (hasOwnProperty.call(obj, key)) keys[keys.length] = key;
|
for (var key in obj) if (hasOwnProperty.call(obj, key)) keys[keys.length] = key;
|
||||||
return keys;
|
return keys;
|
||||||
|
|||||||
Reference in New Issue
Block a user