(1)var obj = {}; //创建空对象
(2)var obj = Object.create(null);
obj.toString //undefined
var obj = Object.create({x:1});
obj.x //1
typeof obj.toString //“function”
(3)工厂模式
function createPerson(name,age,job){
var obj = new Object;
obj.name = name;
return obj;
}
(4)构造函数模式
function Person(name,age,job){this.name = name;}
var person1 = new Person(‘Tom’,20,‘Teacher’);
(5)原型模式
function Person(){}
Person.prototype.name = ‘Grey’;
Person.prototype.age=20;