Last active
March 1, 2018 15:53
-
-
Save Gyumeijie/db8dd7636dae0ee86c6737b4f7f9a9f6 to your computer and use it in GitHub Desktop.
ES6
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
###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