Brendan Eich <mailto:[email protected]>
January 24, 2012 9:49 AM
More fun:

js> function f(k) {
  for (var i = 0; i < k; i++) {
    const j = i*i;
    a.push(j);
  }
}
js> a = []
[]
js> f(10)
js> a
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

Better example:

js> function f(k) {
  print(j);
  for (var i=0; i<k; i++) {
    const j = i*i;
    a.push(j);
    b.push(function(){return j});
  }
}
js> a = [], b = []
[]
js> f(10)
undefined
js> a
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
js> b[0]()
81

Again, none of this is for standardization. Quirky as heck, but we hope sane users treat SpiderMonkey const like top level ES6 const and won't be broken by an incompatible change to conform.

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

Reply via email to