Last active
March 23, 2016 23:43
-
-
Save barneycarroll/6671463fbe593b2bd8a8 to your computer and use it in GitHub Desktop.
Execute multiple functions where one is expected. Useful for event handling.
This file contains 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
function multi(){ | |
var handlers = Array.prototype.filter.call( arguments, function( x ){ | |
return x instanceof Function | |
} ) | |
return function handle(){ | |
for( var i = 0; i < handlers.length; i++ ) | |
handlers[ i ].apply( this, arguments ) | |
} | |
} |
An alternative name for this function is doAll
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use case:
onKey function here