From f29785a0b7871ddbc6dd86da233ae9031d57c857 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Mon, 14 Nov 2011 14:27:44 -0500 Subject: [PATCH] cleaning up _.last implementation. --- underscore.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/underscore.js b/underscore.js index 0079954ec..8a8233335 100644 --- a/underscore.js +++ b/underscore.js @@ -335,7 +335,11 @@ // Get the last element of an array. Passing **n** will return the last N // values in the array. The **guard** check allows it to work with `_.map`. _.last = function(array, n, guard) { - return (n != null) && !guard ? slice.call(array, Math.max(array.length - n, 0)) : array[array.length - 1]; + if ((n != null) && !guard) { + return slice.call(array, Math.max(array.length - n, 0)); + } else { + return array[array.length - 1]; + } }; // Returns everything but the first entry of the array. Aliased as `tail`.