InterviewHubPRO
Section Overview
Q426

Question 426 of 521

Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)

82%
JavaScript Internals (521 Qs)•Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)

How do you define instance and non-instance properties

The Instance properties must be defined inside of class methods. For example, name and age properties defined inside constructor as below,

javascript
 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,

javascript
 Person.staticAge = 30;
 Person.prototype.prototypeAge = 40;