Given an Array of Functions fns
, what argument(s) can you pass to fns.forEach
such that each function in fns
will execute, in order, without creating any anonymous (or named) functions or invoking the Function
constructor?
- Do not use the
function
keyword, or arrow functions() =>
. - Do not invoke the
Function
constructor. - Do not use method definitions.
Function#bind
& friends on theFunction.prototype
are ok.- Answer should be a single line.
- Try for clarity of concept rather than fewest characters; Reduce prototypical lookup to an absolute minimum.
- Create no variables nor use any flow control structures i.e. no loops.
- No Asynchrony (?!)
- No unnecessary semicolons (just because)
Once you have a solution that works, make sure you can explain exactly why it works, and why your previous solutions didn't work.
- https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Function/prototype
- There's also a particularly elegant solution that uses an API introduced in ES2015.
Do feel free to tweet them at me https://twitter.com/secoif
@subshad yep, I think that would spoil the fun. You can tweet them at me on twitter.