Menu

JavaScript and Static Methods

JavaScript and static methods are something special, they don't work as you expect it form an object oriented language. That's because JavaScript is prototyped.

Take the following example:

:::javascript
function A () {
}

A.nodeName = function () {
alert("Name is A");
}

A.prototype.doSomething = function() {
alert("doSomething");
}

/A.prototype.nodeName = function() {
return this.proto.constructor.nodeName();
}
/

A.nodeName();

var a = new A()
a.nodeName();

Posted by Thomas Schmid 2012-03-26 | Draft

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.