Skip to content

Instantly share code, notes, and snippets.

@ice2heart
Created July 11, 2018 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ice2heart/a5130a997bb5ed3f829bf1394f0b048f to your computer and use it in GitHub Desktop.
Save ice2heart/a5130a997bb5ed3f829bf1394f0b048f to your computer and use it in GitHub Desktop.
JS test
const modern = arr => a.map(i => () => i);
function oldStyle(arr) {
var res = [];
var func = function(i) {
return i;
};
for (var i = 0; i <= arr.length; ++i) {
res.push(func.bind(null, arr[i]));
}
return res;
}
let a = [1, 2, 3, 4];
console.log(modern(a)[0]());
console.log(oldStyle(a)[0]());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment