From 20183bbd578cf6da6699928cd13501b0b688ed3a Mon Sep 17 00:00:00 2001 From: jdalton Date: Sun, 12 Apr 2015 10:33:34 -0700 Subject: [PATCH] Have `baseMap` use `getLength` and `isLength`. --- lodash.src.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lodash.src.js b/lodash.src.js index 833531273..a0b2bbaf7 100644 --- a/lodash.src.js +++ b/lodash.src.js @@ -2475,9 +2475,12 @@ * @returns {Array} Returns the new mapped array. */ function baseMap(collection, iteratee) { - var result = []; + var index = -1, + length = getLength(collection), + result = isLength(length) ? Array(length) : []; + baseEach(collection, function(value, key, collection) { - result.push(iteratee(value, key, collection)); + result[++index] = iteratee(value, key, collection); }); return result; }