Note: The core libraries in the cores class are the moo.js and utility.js,moo.js that contain the underlying classes that implement OO, and Utility.js provides the most commonly used tool-function encapsulation.
---------------------------Moo.js-------------------------------------
1.mootools constructs the object using the following form:
var Cat = new Class ({
Initialize:function (name) {
THIS.name = name;
}
});
var cat = new Cat (' Kitty ');
alert (cat.name);
2.Class to inherit, MooTools is doing this:
var Animal = new Class ({
Initialize:function (name) {
THIS.name = name;
}
});
var Cat = Animal.extend ({
Initialize:function (name,age) {
This.parent (name); Call the animal Initialize method
This.age = age;
}
});
The 3.class.implement method extends the class that has already been defined
(For example, add a method), as follows:
var person = new Class ({
Initialize:function (name) {
THIS.name = name;
}
});
Person.implement ({
Initialize:function (name,age) {
THIS.name = name;
This.age = age;
},
Myaction:function () {
Alert (this.name+ '-' +this.age);
}
});
var p = new Person (' zarknight ', 24);
P.myaction ();
MooTools extends a extend method to object, which has two parameters that replicate all the properties of the second parameter object to the first parameter object, and the same name overrides the corresponding property in the second argument:
var Firstob = {
' Name ': ' John ',
' LastName ': ' Doe '
};
var Secondob = {
' Age ': ' 20 ',
' Sex ': ' Male ',
' LastName ': ' Dorian '
};
Object.extend (Firstob, Secondob);
Firstob will become:
{
' Name ': ' John ',
' LastName ': ' Dorian ',
' Age ': ' 20 ',
' Sex ': ' Male '
};
---------------------------Moo.js-------------------------------------
4. $type
Function: Basically an extension of the TypeOf, returning the type of the input parameter
Example:
var x=$type("abcdefg");
return value:
'element'-DOM
'textnode'-DOM文本节点
'whitespace'-DOM空白节点
'array'-数组
'object'-对象
'string'-字符串
'number'-数字
'boolean'-布尔型
'function'-函数
false-if it is undefined or not the type listed above