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

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

前端 js 面試難題,涉及prototype,constructor和instanceof

前端 js 面試難題,涉及prototype,constructor和instanceof

回首憶惘然 2018-08-03 12:02:58
自己遇到的前端面試問題,請高手來幫忙解決。其他的感興趣的同學也可以來看看,自己能不能答對。var A = function() {};A.prototype = {};var B = {};console.log(A.constructor);//Functionconsole.log(B.constructor);//Objectvar a = new A();A.prototype = {};var b = new A();b.constructor = A.constructor;console.log(a.constructor == A);//falseconsole.log(a.constructor == b.constructor);//falseconsole.log(a instanceof A);//falseconsole.log(b instanceof A);//true小弟對最后兩個console.log的結果不明白,我覺得應該是console.log(a instanceof A);// trueconsole.log(b instanceof A);//true但是在瀏覽器中試過了,確實是上面的答案,求解,提前謝謝各位。
查看完整描述

1 回答

  • 1 回答
  • 1 關注
  • 1298 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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