Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_.first and _.last should check length #2495

Closed
jdalton opened this issue Apr 12, 2016 · 1 comment
Closed

_.first and _.last should check length #2495

jdalton opened this issue Apr 12, 2016 · 1 comment
Labels

Comments

@jdalton
Copy link
Contributor

jdalton commented Apr 12, 2016

Array.prototype[0] = 'boo';
_.first([]) // 'boo'

or

var arr = [];
arr[-1] = 'boo'
_.last(arr); // 'boo'
@jridgewell jridgewell added the bug label Apr 12, 2016
xcodebuild added a commit to xcodebuild/underscore that referenced this issue Apr 24, 2016
jridgewell added a commit that referenced this issue Apr 24, 2016
@tgolen
Copy link

tgolen commented May 29, 2018

This had the unfortunately bad side effect of:

Before:

_([]).first(500);
[]

After:

_([]).first(500)
undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants