Skip to content

Instantly share code, notes, and snippets.

@kgarfinkel
Created October 19, 2013 23:47
Show Gist options
  • Save kgarfinkel/7062984 to your computer and use it in GitHub Desktop.
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.
_.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