Created
November 19, 2013 18:38
-
-
Save predic8/7550239 to your computer and use it in GitHub Desktop.
Takes a function with a parameter list and returns a function that takes an array contatning the parameters.
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 splat(fn) { | |
return function(array) { | |
return fn.apply(null, array); | |
}; | |
} | |
var power = splat(Math.pow); | |
console.log( power([2,8])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment