亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

expressjs 源碼 為什么用mixin拓展app, 而不是像下面用Object.create

expressjs 源碼 為什么用mixin拓展app, 而不是像下面用Object.create

一只名叫tom的貓 2019-03-05 13:15:03
function createApplication() {  var app = function(req, res, next) {    app.handle(req, res, next);  };  mixin(app, EventEmitter.prototype, false);  mixin(app, proto, false);  // expose the prototype that will get set on requests  app.request = Object.create(req, {    app: { configurable: true, enumerable: true, writable: true, value: app }  })  // expose the prototype that will get set on responses  app.response = Object.create(res, {    app: { configurable: true, enumerable: true, writable: true, value: app }  })  app.init();  return app;}代碼Github頁面地址點擊這里
查看完整描述

1 回答

?
慕的地8271018

TA貢獻1796條經驗 獲得超4個贊

mixin不會改變目標對象的原型,會在原有對象基礎上增加(或者說混入)新的屬性,而Object.create是創建一個指定原型和若干屬性的對象。


查看完整回答
反對 回復 2019-03-16
  • 1 回答
  • 0 關注
  • 513 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號