Skip to content

Instantly share code, notes, and snippets.

@ginpei
Created May 22, 2013 21:01
Show Gist options
  • Save ginpei/5630870 to your computer and use it in GitHub Desktop.
Save ginpei/5630870 to your computer and use it in GitHub Desktop.
var obj1 = { name:'Alice' };
var obj2 = { name:'Bob' };
function say(talk, age) {
console.log(talk + ', I am ' + this.name + ', ' + age + ' years old.');
}
say.apply(obj1, ['Hi', 12]); // "Hi, I am Alice, 12 years old."
say.apply(obj2, ['Good morning', 36]); // "Good morning, I am Bob, 36 years old."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment