Assigning to 'this' because it happens that 'this' is global is no better and perhaps worse than using undeclared variables for globals. Assignments to global have, well, non-local consequences: they should be explicit not context dependent.
Even if you don't agree, node has made "global" the de facto standard; lots of code is now written with the (function(global) {...}(typeof global !== 'undefined' ? global : this)); goop. Modules avoid the smaller part of that boilerplate but we still don't solve it all without a way to say "global". On Thu, Jun 5, 2014 at 7:34 AM, Andreas Rossberg <rossb...@google.com> wrote: > On 5 June 2014 16:08, John Barton <johnjbar...@google.com> wrote: > > On Thu, Jun 5, 2014 at 2:06 AM, Andreas Rossberg <rossb...@google.com> > > wrote: > >> > >> On 4 June 2014 23:46, John Lenz <concavel...@gmail.com> wrote: > >> > I don't personally want to write sloppy mode code, but there are > places > >> > you > >> > need it (using eval to introduce new symbols into global scope). > >> > >> You don't necessarily need sloppy mode for that. In strict mode, you > >> can still express it as assignment to the global object. > > > > This excellent solution would be much more widely adopted if the global > > object had a standard identifier, like say "global". > > Hm, I'm not sure why that would be a problem. What's wrong with using > 'this' inside those evals? > > /Andreas >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss