Created
January 21, 2017 23:28
-
-
Save solominh/b289630749d54470e5ca9cd1d329ded7 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 Person { | |
constructor(name) { | |
this.name = name; | |
} | |
static realStaticMethod() { | |
console.log('static method'); | |
} | |
} | |
var john = new Person('john'); | |
// Real static method | |
john.realStaticMethod() // Error => static cannot be accessed by instance | |
Person.realStaticMethod() // static method | |
Person.prototype.realStaticMethod() // undefined => run Error | |
john.__proto__.constructor.realStaticMethod() // static method | |
// Real static property | |
Person.realStaticProperty = 10; | |
john.realStaticProperty // undefined | |
john.__proto__.constructor.realStaticProperty // 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment