Skip to content

Instantly share code, notes, and snippets.

@AnimeshPandey
Last active February 27, 2021 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AnimeshPandey/635a3ba11e528944e2bac871698f03c3 to your computer and use it in GitHub Desktop.
Save AnimeshPandey/635a3ba11e528944e2bac871698f03c3 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
// Example 3. Simple Implicit Binding
function getBaseSpeed(){
console.log("Base Speed Stat is : ", this.baseSpeed);
}
var pikachu = {
baseSpeed : 90,
getBaseSpeed : getBaseSpeed
};
pikachu.getBaseSpeed();
// Output
// Base Speed Stat is : 90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment