Thursday, March 8, 2018

oop - Creating "static" members in a javascript object





Is there a way to create "static" members in a JS Object?



function Person(){

}


Person.prototype.age = null;
Person.prototype.gender = null;


I would like to add personsCount as a static member, is that possible?


Answer



Sure, just add Person.personsCount without the prototype


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...