Created
February 27, 2021 23:59
-
-
Save AnimeshPandey/cc8d8ef4bff6298260e589c6f428eeb3 to your computer and use it in GitHub Desktop.
Helpful example code to demonstrate the use of "this" in JavaScript for my article at https://anmshpndy.medium.com/how-well-do-you-know-this-ce4355bc9b
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
// Example 9. Simple 'this' binding in case of new | |
function setPokémon(name) { | |
this.name = name; | |
} | |
var catchPokémon = new setPokémon("Blastoise"); | |
console.log(catchPokémon.name); | |
// Output | |
// "Blastoise" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment