Created
July 21, 2017 22:54
-
-
Save fabiobiondi/1938e555a36179f858018a1878b459b0 to your computer and use it in GitHub Desktop.
ES6 - Class - Preserving context with arrow syntax
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
class MyClass { | |
text = 'Mario'; | |
constructor() { | |
setTimeout(() => console.log(this.text), 1000); | |
} | |
} | |
var a = new MyClass(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment