Skip to content

Instantly share code, notes, and snippets.

@Gyumeijie
Last active March 1, 2018 15:53
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 Gyumeijie/db8dd7636dae0ee86c6737b4f7f9a9f6 to your computer and use it in GitHub Desktop.
Save Gyumeijie/db8dd7636dae0ee86c6737b4f7f9a9f6 to your computer and use it in GitHub Desktop.
ES6
###Arrow functions do not have this, arguments or other special names bound at all###
when the object is being created the name this is found in the enclosing scope.
name="YMJ"
var person = {
name: "ymj",
shout: () => console.log("my name is ", this.name)
}
person.shout() // ymj
`this` points at the nearest bound `this` - in the code provided `this` is found in the enclosing scope, in this
case it is window object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment