Created
March 23, 2017 12:10
-
-
Save ppraksa/9f4787fbd8b31e8a3483282905878581 to your computer and use it in GitHub Desktop.
'this' scope on arrow fn
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
var a = 2; | |
var Obj = { | |
a: 4, | |
test: () => { | |
console.log(a); | |
console.log(this.a); | |
}, | |
test2: function({a = 6}) { | |
console.log(a); | |
console.log(this.a); | |
} | |
} | |
Obj.test2({a: 2}) // this.a nice and correct | |
Obj.test(); // wtf? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment