UNPKG

308 BJavaScriptView Raw
1"use strict";
2var arr = [];
3
4// can be transformed (common WAT)
5for (var x = 0; x < 10; x++) {
6 arr.push(function() { return x; });
7}
8
9// can be transformed
10for (let x in [0,1,2]) {
11 arr.push((function(x) { return function() { return x; } })(x));
12}
13
14arr.forEach(function(f) {
15 console.log(f());
16});