Created
September 24, 2019 06:42
-
-
Save a1exlism/b17473a8c3091bc399d58603343ec4bc to your computer and use it in GitHub Desktop.
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 Test { | |
constructor() { | |
this.data = { | |
name: null, | |
age: -1, | |
attr: null | |
} | |
} | |
init() { | |
this.data = { | |
name: 'Alice', | |
age: 5, | |
attr: this.data.name + ' is ' + this.data.age + ' year old.' | |
} | |
} | |
} | |
a.init() | |
// undefined | |
a.data.attr | |
// "null is -1 year old." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment