, dojo.js writing style
Dojo is the latest 1.3.1, remember 07 years or 0.4. The documentation is getting more and more slowly with dojo too. Dojo also released the core version, only 27kb after compression. Dojo uses the Dojo.declare method to define a class. Dojo.declare's source code is not posted here. Dojo.declare has three parameters,
Parameter 1: class name classname
Parameter 2: inherited class Superclass
Parameter 3: constructor, method props
Simply defining a class is actually just passing first, 32 parameters. Because this is just a discussion of how to define a class and not to discuss inheritance. The code is as follows:
Copy Code code as follows:
//definition class name
var className = "Person";
//define constructors and methods
var proto = {
Constructor:function (name) {this.name=name;},
Getname:function () {return THIS.name},
Setname:function (name) {this.name = name;}
}
//define Class person
Dojo.declare (Classname,null,proto);
//Create an object
var p = new Person ("Tom");
Console.log (P.getname ());//tom
P.setname ("Jack");
Console.log (P.getname ());//jack
//test instanceof and P.constructor correctly point to Person
Console.log (p instanceof person);//true
Console.log (p.constructor = = person);//true