Thursday, 8 March 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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...