From 8c07a67fe98ef0b632e01e3692f8c211a2fdaaae Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 8 Sep 2013 15:09:09 -0600 Subject: [PATCH] Ensure `_.sample` handles falsey `collection` arguments. --- lodash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lodash.js b/lodash.js index 863a572f6..3ebd5d253 100644 --- a/lodash.js +++ b/lodash.js @@ -3895,7 +3895,7 @@ collection = collection.split(''); } if (n == null || guard) { - return collection[random(length - 1)]; + return collection ? collection[random(length - 1)] : undefined; } var result = shuffle(collection); result.length = nativeMin(nativeMax(0, n), result.length);