Created
October 19, 2013 23:47
-
-
Save kgarfinkel/7062984 to your computer and use it in GitHub Desktop.
_.first return's an array of the first n elements of an array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.first = function(array, n) { | |
if (n === undefined) { | |
return array[0]; | |
} | |
return slice.call(array, 0, n); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment