1.object构造函数创建
var obj=new Object();
obj.name='xue';
2.对象字面量创建
var obj={
name:'xue'
}
3.构造函数创建
function Person(name){
this.name=name
}
var person=new Person('xue')
3.工厂函数创建
function Person(name,age){
var obj=new Object();
obj.name=name;
return obj;
}
var person=new Person('xue')
4.原型创建
function Person(name){
Person.prototype.name=name;
}
var people=new Person('xue')
5.原型加构造函数
function Person(name){
this.name=name;
}
Person.prototype={
constructor:Person,
play:function(){
........
}
}
var person=new Person('xue')