mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
delegate to ECMA5 native Array.isArray if available
This commit is contained in:
@@ -415,7 +415,7 @@
|
|||||||
// ------------------------- Object Functions: ------------------------------
|
// ------------------------- Object Functions: ------------------------------
|
||||||
|
|
||||||
// Retrieve the names of an object's properties.
|
// Retrieve the names of an object's properties.
|
||||||
// ECMA5 has Object.keys(obj) in webkit nightlies
|
// Delegates to ECMA5's native Object.keys
|
||||||
_.keys = Object.keys || function(obj) {
|
_.keys = Object.keys || function(obj) {
|
||||||
if (_.isArray(obj)) return _.range(0, obj.length);
|
if (_.isArray(obj)) return _.range(0, obj.length);
|
||||||
var keys = [];
|
var keys = [];
|
||||||
@@ -526,7 +526,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Is a given value an array?
|
// Is a given value an array?
|
||||||
_.isArray = function(obj) {
|
// Delegates to ECMA5's native Array.isArray
|
||||||
|
_.isArray = Array.isArray || function(obj) {
|
||||||
return !!(obj && obj.concat && obj.unshift);
|
return !!(obj && obj.concat && obj.unshift);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user