From b774bf7ca9770625c0dffa99d46c14f22fdf7776 Mon Sep 17 00:00:00 2001 From: Mike Frawley Date: Mon, 22 Feb 2010 14:37:54 -0600 Subject: [PATCH] delegate to ECMA5 native Array.isArray if available --- underscore.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/underscore.js b/underscore.js index cf6a1578e..bd74fbcf5 100644 --- a/underscore.js +++ b/underscore.js @@ -415,7 +415,7 @@ // ------------------------- Object Functions: ------------------------------ // 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) { if (_.isArray(obj)) return _.range(0, obj.length); var keys = []; @@ -526,7 +526,8 @@ }; // 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); };