JavaScript is a strong object-oriented language, support the creation of instances and then add properties and methods, although it is a small skill, easy to forget, today wrote a very small example, recorded here, for reference only.
function MyClass ()
{
//this function is same as a constructer
alert ("New Object Created");
}
Creating Object
var MyObject = new MyClass ();
Newobject.prototype =
{
//adding method named ' MyMethod '
mymethod:function () {alert (' my method ');
//adding Property named "MyProperty"
MyProperty: ' My Property '
}
//calling method
Myobject.mymethod ();
Assigning property
A small example, the master do not spray, welcome message exchange.
The above is a small set for everyone to create the JavaScript class and dynamically add properties and methods of simple implementation of the whole content, I hope that we support the cloud Habitat Community ~