
下面这段代码如何理解,求教! 30
varClass={create:function()//createFunction{returnfunction(){this.initialize.apply(th...
var Class = {
create: function() // create Function
{
return function()
{
this.initialize.apply(this, arguments);
}
}
};
var Person = Class.create(); // Create Class Person
Person.prototype = { // prototype initialize
initialize: function(obj1, obj2)
{
this.obj1 = obj1;
this.obj2 = obj2;
},
showSelf: function()
{
alert("obj: " + this.obj1 + " and " + this.obj2);
}
}
// instance Class
var person = new Person("man", "women"); // two params
person.showSelf(); // show person
person应该是function()
{
this.initialize.apply(this, arguments);
}
但是new Person("man", "women"); 这个怎么理解呢?为什么会有两个参数呢? 展开
create: function() // create Function
{
return function()
{
this.initialize.apply(this, arguments);
}
}
};
var Person = Class.create(); // Create Class Person
Person.prototype = { // prototype initialize
initialize: function(obj1, obj2)
{
this.obj1 = obj1;
this.obj2 = obj2;
},
showSelf: function()
{
alert("obj: " + this.obj1 + " and " + this.obj2);
}
}
// instance Class
var person = new Person("man", "women"); // two params
person.showSelf(); // show person
person应该是function()
{
this.initialize.apply(this, arguments);
}
但是new Person("man", "women"); 这个怎么理解呢?为什么会有两个参数呢? 展开
展开全部
不清楚这什么语言。看意思person是类吧。两个参数是初始化obj1,obj2这两个成员变量的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询