Skip to content

Instantly share code, notes, and snippets.

@ahmarsuhail
Created July 16, 2019 19:06
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 ahmarsuhail/f5cf690ba4bfd2eb091f2fb9141208b4 to your computer and use it in GitHub Desktop.
Save ahmarsuhail/f5cf690ba4bfd2eb091f2fb9141208b4 to your computer and use it in GitHub Desktop.
const user = {
name: "Ahmar",
keys: [1, 2, 3],
printName: function() {
this.keys.forEach(function(x) {
console.log(this.name);
})
}
}
user.printName(); //Error: Cannot read property 'name' of undefined"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment