function Person() {}
Person.prototype.population = 0;
Person.prototype.constructor = function(name) {
this.name = name;
console.log("Name: " + this.name);
console.log("Population: " + (++this.population) );
}
var p = new Person("Wex");
The following code doesn’t seem to work, although logically I feel like it seems sound. How come this doesn’t display the name and population?
http://jsfiddle.net/zerkms/gvjEF/
As long as you want static class variable you need:
classname.varnamethis