1、var obj = {}; //创建一个临时对象;
2、obj.__proto__ = People.prototype; //将该临时对象原型指向构造函数原型
3、People.call(obj, "孙悟空"); //将构造函数中 this 指向临时对象,并传入参数 "孙悟空"
4、return obj; //返回临时对象,person 指向创建的 obj 对象(对象类型赋值为按引用传递,obj 与 person 指向同一个对象)
//创建构造函数 function People(name){ this.name = name; } //使用new创建实例对象person var person = new People("孙悟空"); person = { name: "孙悟空" } var person = function(){ var obj = {}; obj.__proto__ = People.prototype; People.call(obj, "孙悟空"); return obj; }()//使用立即执行函数(IIFE) person = { name: "孙悟空" }