From ee24bbc38ad6541a46a86f516c9e971891fd6064 Mon Sep 17 00:00:00 2001 From: stonelee Date: Mon, 18 Mar 2013 10:51:18 +0800 Subject: [PATCH] unify the way to adding to array.fix Issue #1025 --- underscore.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/underscore.js b/underscore.js index 582e737bf..9b314e074 100644 --- a/underscore.js +++ b/underscore.js @@ -747,14 +747,14 @@ // Retrieve the values of an object's properties. _.values = function(obj) { var values = []; - for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); + for (var key in obj) if (_.has(obj, key)) values[values.length] = obj[key]; return values; }; // Convert an object into a list of `[key, value]` pairs. _.pairs = function(obj) { var pairs = []; - for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); + for (var key in obj) if (_.has(obj, key)) pairs[pairs.length] = [key, obj[key]]; return pairs; }; @@ -770,7 +770,7 @@ _.functions = _.methods = function(obj) { var names = []; for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); + if (_.isFunction(obj[key])) names[names.length] = key; } return names.sort(); };