Skip to content

Instantly share code, notes, and snippets.

@davidsharp
Created November 9, 2016 15:07
Show Gist options
  • Select an option

  • Save davidsharp/20bb5b31272138a3d52e511bc1affc48 to your computer and use it in GitHub Desktop.

Select an option

Save davidsharp/20bb5b31272138a3d52e511bc1affc48 to your computer and use it in GitHub Desktop.
A dumb ES6+ function for running multiple functions without parameters, with return values in a neat array
const run = (...args) => (args.map(f=>f()))
@davidsharp

Copy link
Copy Markdown
Author

What's extra dumb about this is that it doesn't work with arrays, which is something you might even find useful to match functions with their output.

If you really fancy doing that though run(...functionArray) will do the job.

(I guess I could reduce the array if I get one, but where's the fun in that?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment