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

Array.prototype.find is always shimmed #433

Closed
zerovox opened this issue Jan 23, 2017 · 3 comments
Closed

Array.prototype.find is always shimmed #433

zerovox opened this issue Jan 23, 2017 · 3 comments

Comments

@zerovox
Copy link

zerovox commented Jan 23, 2017

if (![, 1].find(function (item, idx) { return idx === 0; })) {
  overrideNative(Array.prototype, 'find', ArrayPrototypeShims.find);
}

I believe this will shim find if the behaviour of find is correct. [, 1].find(function (item, idx) { return idx === 0; }) should return undefined (assuming my understanding that [, 1] should act the same as [undefined, 1], so we want to shim if it returns 1. This means the negation is placed incorrectly.

@ljharb
Copy link
Collaborator

ljharb commented Jan 23, 2017

That's not entirely accurate - we want to shim if it reaches the iteration of index 1 - but you're correct that this seems wrong, because of the undefined.

I'll get a fix out for this shortly.

@ljharb
Copy link
Collaborator

ljharb commented Jan 23, 2017

(note that this isn't breaking anything, it's just needlessly shimming)

@ljharb ljharb closed this as completed in 449b794 Jan 23, 2017
ljharb added a commit to paulmillr/Array.prototype.find that referenced this issue Jan 23, 2017
@ljharb
Copy link
Collaborator

ljharb commented Jan 24, 2017

Published as v0.35.3.

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

No branches or pull requests

2 participants