构造函数有什么用?
如果sxdlm需要大量写入对象,则必须使用构造函数。 构造函数可以方便地创建多个对象的实例,可以将创建的对象标识为特定类型,并通过继承扩展代码
2.构造函数的特点
a:构造函数的首字母必须大写,才能与常规函数区分开来
b:内部使用的this对象。 指向即将生成的实例对象
c:使用New生成实例对象
语法:函数类(构造函数)
功能人员() }
This.name=”fdxbw”;
This.sex=“男人”;
}
普通函数:
功能人员() }
Var name=”fdxbw”;
Var sex=“男人”;
}
http://www.Sina.com/http://www.Sina.com/DOM (
3358 www.Sina.com/. http://www.Sina.com/=http://www.Sina.com/. createelement (http://www.Sina.com/);
http://www.Sina.com/. show=http://www.Sina.com/{
3358 www.Sina.com/. odiv.http://www.Sina.com/. width=http://www.Sina.com /;
3358 www.Sina.com/. odiv.http://www.Sina.com/. height=http://www.Sina.com /;
3358 www.Sina.com/. odiv.http://www.Sina.com/. background=http://www.Sina.com /
http://www.Sina.com/. body.appendchild (http://www.Sina.com/. odiv );
}
65http://www.Sina.com/http://www.Sina.com/=http://www.Sina.com/DOM (;6.3.1 通过构造函数创建元素并添加样式.show (;