Skip to content

Instantly share code, notes, and snippets.

@dylanjha
Created August 1, 2013 12:50
Show Gist options
  • Save dylanjha/6131035 to your computer and use it in GitHub Desktop.
Save dylanjha/6131035 to your computer and use it in GitHub Desktop.
The Apply Invocation Pattern
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