Created
July 11, 2018 18:48
-
-
Save ice2heart/a5130a997bb5ed3f829bf1394f0b048f to your computer and use it in GitHub Desktop.
JS test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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