构造对象的三种方式

1.对象字面量

var a = {
  name: 'Jack'
}

其prototype指向Object.prototype

2.构造函数

function A(){};
var a = new A();

等价于

function A(){};

var a = {};
a.__proto__ = A.prototype;
A.call(a);

其prototype指向构造函数的prototype指向的对象

3.Object.create

var a = {
  name: 'Jack'
}
var b = Object.create(a);

其prototype指向a

参考:https://www.zhihu.com/question/34183746/answer/58068402

推荐阅读更多精彩内容