Skip to content

Instantly share code, notes, and snippets.

@openhoat
Created December 24, 2015 10:02
Show Gist options
  • Save openhoat/7320dae541a540275248 to your computer and use it in GitHub Desktop.
Save openhoat/7320dae541a540275248 to your computer and use it in GitHub Desktop.
Execute an array of function in one line
var funcs = [
function hello() {
console.log('hello');
},
function world() {
console.log('world');
},
function foo() {
console.log('foo');
},
function bar() {
console.log('bar');
}];
Array.prototype.forEach.apply(funcs, Array.apply(null, Array(2)).map(Object.prototype.valueOf, Function.prototype.call));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment