`self` is a very common local variable name, usually used as a substitute of `this`.
 
So making it a global variable is a terrible idea. Consider this:
 
```
function blah() {}
 
blah.prototype.foo = function () {
  var self = this
 
  asyncStuff(function () {
    self.complete = true
  })
}
```
 
So what happens if you forget that `var self` declaration? Right now in server-side js it's a good old reference error.
 
But if `self` gets adopted, this code will not always fail, but will lead to mistakes (global variable named `complete` in this example).
 
I'd much rather have "window" and "global" as is honestly.
 
 
17.04.2015, 18:02, "Boris Zbarsky" <bzbar...@mit.edu>:

On 4/17/15 10:55 AM, Andrea Giammarchi wrote:

 We have `window` in DOM land, `self` in Workers

We have `self` in DOM land too, so you can consistently use `self`
across Window and Workers.

 and `global` in most common server side JS engines

Sounds like they should add `self`.  ;)

-Boris
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to