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
JavaScript: Avoid referring to arguments
#371
Conversation
*Avoid* using `arguments` unnecessarily. Inspired by [petkaantonov/bluebird][wiki]'s "Optimization Killers" wiki. Using `arguments` without `.length` or `[i]` makes it nearly impossible for V8 to optimize the function block. [wiki]: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
a0ece5b
to
652966a
Compare
👍 |
2 similar comments
👍 |
👍 |
Yup, makes sense. (And you don't need this anymore with the argument spread syntax.) |
@mcmire avoiding |
Oh, I thought this was addressing avoiding referring to AFAIK, the spread syntax actually creates a new variable that is non-special. (You could write |
@mcmire I'm not sure. @BlakeWilliams made that comment that inspired this PR, so maybe he know for certain. |
This example shows that it's still using |
Ah, good to know, thanks. It seems like the following syntax is prohibited in strict mode, as well: function foo(...arguments) {
// ...
} However, you can say this: function foo(...args) {
// ...
} So, do you think that this is useful to distinguish? i.e. something like "As an alternative to |
I think it's worth mentioning an alternative any time we recommend against something. 👍 to |
@mcmire @BlakeWilliams I've pushed an update with a sample. |
Sweet, looks good! |
Looks great! |
During this deep dive into Ember.View, @rwjblue replaces EDITED |
Technically, I replaced Also, the article referenced specifically states that calling |
@BlakeWilliams from the wiki:
From your example:
|
Given this new information, I'm closing this PR. |
Avoid using
arguments
unnecessarily.Inspired by petkaantonov/bluebird's "Optimization Killers"
wiki.
Using
arguments
without.length
or[i]
makes it nearly impossiblefor V8 to optimize the function block.