Skip to content

Instantly share code, notes, and snippets.

@JunPyoL22
Last active March 17, 2018 14:57
Show Gist options
  • Save JunPyoL22/5a18e627983c20b6b8dcedd4bcc71bc1 to your computer and use it in GitHub Desktop.
Save JunPyoL22/5a18e627983c20b6b8dcedd4bcc71bc1 to your computer and use it in GitHub Desktop.
function price() {
return this.price;
}
function howMuchIsIt() {
var ans = "It's " + price.call( this ) + ' worth';
console.log( ans );
}
var productA = {
price: "$150"
};
var productB = {
price: "$200"
};
price.call( productA ); // $150
price.call( productB ); // $200
howMuchIsIt.call( productA ); // It's $150 worth
howMuchIsIt.call( productB ); // It's $200 worth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment