Ext.apply and ext.applyif
Ext.onready (function () {//ext.apply and Ext.applyif) extend the properties or methods of the object var src1={name: ' Zhang San ', age:23};//the extended object var src2={name: ' Zhang San ', age:23};//extended object var config={name: ' John Doe ', Sex: ' Male '};//config object//use ext.apply to extend, overwrite the original property or method Ext.apply (src1,config); for (Var attr in Src1) {alert (attr+ ': ' +src1[attr]);} Extend with Ext.applyif, if the property or method originally exists, do not replace ext.applyif (src2,config); for (Var attr in src2) {alert (attr+ ': ' +src2[attr]);}});
Results:
Ext.override Method (overwrite)
Ext.onready (function () {ext.define (' User ', {say:function ()///Definition Method {alert (' Say ... ');}}); var user=ext.create (' user '); Ext.override (user,{//method overrides Say:function () {alert (' This is an override method ... ');}}); User.say ();//Call Method});
Results:
Other methods:
Ext.onready (function () {//typeof method, like Var str= ' string ' in JavaScript, alert (' type is: ' +ext.typeof (str));//isarray etc is ... Method, refer directly to help document VAR Arr=[1,2];alert (Ext.isarray (arr)),//iterate method, Traverse ext.iterate (Arr,function (item) {alert (item);});});
Results: