Created
May 18, 2016 10:27
-
-
Save AlexanderZeilmann/7fa9b24cb2941dc414bbd671b66bd0ad to your computer and use it in GitHub Desktop.
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
// the array of functions | |
const fns = [ | |
function () { | |
console.log(1) | |
}, | |
function () { | |
console.log(2) | |
}, | |
function () { | |
console.log(3) | |
} | |
] | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions | |
const call = {key(func) {func()}}.key | |
fns.forEach(call) // change this line if you like | |
// Expected console output should be | |
// 1 | |
// 2 | |
// 3 |
Though you're the first one to use this trick so you get some points for creativity 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It does mention "do not create named functions". Updated gist to explicitly disallow method definitions.