Home  >  Article  >  Web Front-end  >  Detailed explanation of prototype class_javascript skills

Detailed explanation of prototype class_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:26:241087browse

//Perfume is bad 06-07-19 TKS: Linzi, provide a place for everyone to communicate and share
var Class = {
create: function() {
return function() {
this .initialize.apply(this, arguments);
}
}
}
can be rewritten as follows: it may be clearer:
var Class={
create:function( ){
return cls_initfunc
}
}

var cls_initfunc = function()
{
this.initialize.apply( this,arguments);
}

//The create method of the above Class object obviously returns an object construction function
//At the same time, execute the this.apply method in the component function to initialize the object
//This parameter is used for replacement Object, arguments are the parameters accepted by the initialize function. By executing " " (this, arguments);
}
obj.prototype={
initialize:function(){
//do ur init in here
},

,


}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn