;(function() {
  var x = 2
 
  ;(function(x) {
    x = 100
    x // x = 100
  })(x)
 
  x // x = 2
})()
 
Wow, it works already. You just have to write a bit less semicolons there. Merry Christmas! :)
 
Also this:
 
;(function() {
  var x = 2
 
  with({x: x}) {
    x = 100
    x // x = 100
  }
 
  x // x = 2
})()
 
But js engines don't appreciate that one. :(
 
 
24.12.2013, 21:10, "raul mihaila" <[email protected]>:
Merry Christmas!
 
Did you consider adding a way for variables to automatically get the value from a variable with the same name from the parent execution context?
 
(function () {
    var x = 2;
    
    (function () {
        local x; // x = 2
        x = 100;
        x; // x = 100
 
        local y; // maybe throw since y was not found anywhere
    })();
 
    x; // x = 2
})(); 
 
This would be useful when optimizing the code so that the variables are as local as possible. Especially useful with calling functions (multiple times) or working heavily with collections from the outer context in the inner functions.
,

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to