Um. What are we achieving through this JS pattern? (taken from here: link) :
// public static
function Person() {
Person.TOTAL++;
}
Person.TOTAL = 0;
Because it seems we can just do:
Person.TOTAL++;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a “public” property, in that it’s gettable and settable outside the class, and it’s “static” because there’s a single instance of the property.
The counter is incremented in the constructor function, but can be modified externally. The pattern makes sense but this use of it is questionable.