new 的模拟实现 
- new 运算符创建一个用户定义的对象类型的实例或具有构造函数的内置对象类型之一
 
new 的操作过程 
创建一个空的简单 JavaScript 对象。为方便起见,我们称之为 newInstance
如果构造函数的 prototype 属性是一个对象,则将 newInstance 的 [[Prototype]] 指向构造函数的这个属性,否则 newInstance 将保持为一个普通对象,其 [[Prototype]] 为 Object.prototype。
因此,通过构造函数创建的所有实例都可以访问添加到构造函数 prototype 属性中的属性/对象。使用给定参数执行构造函数,并将 newInstance 绑定为 this 的上下文
如果构造函数返回非原始值,则该返回值成为整个 new 表达式的结果。否则,如果构造函数未返回任何值或返回了一个原是值,则返回 newInstance
简化版
- 创建一个空的简单 JavaScript 对象(即{});
 - 链接该对象(即设置该对象的构造函数)到另一个对象 ;
 - 将步骤 1 新创建的对象作为 this 的上下文 ;
 - 如果该函数没有返回对象,则返回 this。
 
模拟实现代码 
javascript
function objectFactory() {
  var obj = new Object(),
    Constructor = [].shift.call(arguments);
  obj.__proto__ = Constructor.prototype;
  var ret = Constructor.apply(obj, arguments);
  return typeof ret === "object" ? ret : obj;
}