M
Matt Kruse
VK said:Well, if you are serious in what you are saying then your perception
of JavaScript and especially its inheritance is seriously damaged.
Your bickering is quite unproductive. And you are clearly wrong.
function C() { ; }
C.prototype.n = 5;
var obj = new C;
alert(obj.n); // 5
"Static" properties do not belong to an instance of a class, they belong to
the class itself.
In java, if a class has a static property and you access it as a property of
an instance, the compiler should throw a warning.
In the example above, how would you access the value of n without creating
an instance of C?
The answer is, you can't (other than looking at the prototype directly).
Accessing C.n will not work. If you have to create an instance of a class to
access a "static" property, then it's not a static property.