-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Use of Array.prototype for __slice throws on Array declaration #1973
Comments
Yeah, we should probably reverse the order of declaration. |
Order doesn't matter:
|
Hah, whoops. Can't believe that slipped my mind. |
Ah, of course. Thanks @satyr. Personally, I think __slice = function(){ return this.Array.prototype.slice }() |
@jashkenas: Do you think this is one of those issues that's so pathological it's not even worth fixing? I'm thinking that may be so, especially since the fix negatively effects both the size and execution time of every other program. Another possible fix is to initialise the top-level scope object with all of the built-in constructors and possibly all of the other predefined globals. |
@michaeficarra: What's the perf hit of |
The difference is fairly negligible and the alternative proposal: __slice = function(){ return this.Array.prototype.slice }() has holes:
This is interesting -- weak sandboxing. Seems like a lot of overhead for a limited use-case though (this issue seems to be about user-defined classes with the same name as native |
Illustrating @geraldalewis's point:
|
Since its ran only once and assigned into
Can't we just |
Another option could be to modify I think we have two good options:
__slice = [].slice
Edit: Oops - quite right @shesek - I meant |
|
I think that |
Me too. |
@jed: fixed by the above commit |
awesome. many thanks, @michaelficarra. |
This CoffeeScript
compiles to this JavaScript
which throws because
Array
isundefined
here.Wouldn't it be safer to use
[].slice
instead, since it will always work, or at least reverse the order of declaration?The text was updated successfully, but these errors were encountered: