舉個例子:函數
# 正常建立一個對象 function Super() {}; var s = new Super();
以上其實等價於3個步驟this
# 3個步驟 var s = {}; s.__proto__ = Super.prototype; Super.call(s); # 注:1.2兩步,其實就是Object.create(Super.prototype);
var s = {};
s.__proto__ === Super.prototype
# 把s當作Super中的this,作初始化s的操做 Super.call(s);
# 例如 function Super() { this.y = 1; } # 經過 Super.call(s); # 其實就至關於 Super(_this) { _this.y = 1; } Super(s);