var a = 10; var fn = function (x) { return x + a}; fn(10); ==> 20 var a = 1; fn(10) ==> 11 //WAT ??
Is the above fixed with ES2015 ? Closures need to enclose values and not references.
1. You can solve that already in ES6, by returning fn from a function, also avoiding the global variable;
2. Your ES3 linter should warn you about the redefined variable.
var a = 10; var fn = function (x) { return x + a}; fn(10); ==> 20 var a = 1; fn(10) ==> 11 //WAT ??
Is the above fixed with ES2015 ? Closures need to enclose values and not references.