The Instance properties must be defined inside of class methods. For example, name and age properties defined insider constructor as below:
1 2 3 4 5 6 | class Person { constructor(name, age) { this.name = name; this.age = age; } } |
But Static(class) and prototype data properties must be defined outside of the ClassBody declaration. Let’s assign the age value for Person class as below,
1 2 | Person.staticAge = 30; Person.prototype.prototypeAge = 40; |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.