Created
August 1, 2013 12:50
-
-
Save dylanjha/6131035 to your computer and use it in GitHub Desktop.
The Apply Invocation Pattern
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
myFn = function(msg){ | |
return msg + this.status; | |
} | |
o = { status: "killing it" } | |
myFn.apply(o, ["Your status is: "]) | |
//>> "Your status is: killing it" | |
//call apply on a function, first arg is the value of "this" inside the fn, | |
//2nd arg is an array of parameters for the function. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment