JavaScript and static methods are something special, they don't work as you expect it form an object oriented language.
You coded the following:
function A () {
}
A.nodeName = function () {
alert("Name is A");
}
A.prototype.doSomething = function() {
alert("doSomething");
}
A.nodeName(); // Works perfectly fine
var a = new A()
a.nodeName(); // Does not work at all
Why is the last statement not working at it should? Because JavaScript is a prototyped language. When invoking the constructor, it copies all prototyped functions and variables to the new object. An it's obvious, that A.nodeName is not part of the prototype, so it is not copied.
There are numerous ways to get around this. A rather nice workaround is to add the following snippet.
A.prototype.nodeName = function() {
return this.proto.constructor.nodeName();
}
What does it do? Every object has a reference to it's original prototype (prototype). The original prototype has a reference to the original constructor. Which has again a reference to his originating object. Which is equivalent to our object A which contains the static function.