Microsoft Dynamics Developer
Saturday, 21 April 2012
Javascript Prototypes
//Dynamically add method in class using Prototypes
//Define Class
function Foo()
{
this.x = 1;
}
//Add the new method in class
Foo.prototype.AddX = function(y)
{
this.x += y;
}
obj = new Foo;
obj.AddX(5); //call method
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment