Last active
March 17, 2018 14:57
-
-
Save JunPyoL22/5a18e627983c20b6b8dcedd4bcc71bc1 to your computer and use it in GitHub Desktop.
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 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