JS Pop Quiz: How well do you know your functions?
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
- Do not use the
functionkeyword, or arrow functions
- Do not invoke the
- Do not use method definitions.
Function#bind& friends on the
- 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.
- There's also a particularly elegant solution that uses an API introduced in ES2015.
Please don't post answers here (or in reply to the original tweet)
Do feel free to tweet them at me https://twitter.com/secoif