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

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

在下面的對象原型問題中遇到一些問題

在下面的對象原型問題中遇到一些問題

慕田峪7331174 2022-12-22 15:17:00
我有以下代碼 -function x(a, b) {  this.b = b || 'test';  this.c = false;}x.prototype.z = function() {  if(this.c) {    console.log('hello')  }}let n = function(a, b, v, d) {  x.call(this,a, b);  this.a = a;  this.v = v;  this.d = d;}n.prototype = Object.create(x.prototype);let n1 = new n();為 n1 設置了哪三個屬性?--> 我發現只有 b、c 正在設置。但它要求 3 個選項C和在db
查看完整描述

1 回答

?
Cats萌萌

TA貢獻1805條經驗 獲得超9個贊

這就是 n1 的樣子


{

  a: undefined,

  b: "test",

  c: false,

  d: undefined,

  v: undefined,

  z: function() {

    if (this.c) {

      console.log('hello')

    }

  }

}

z 也有一個值,因為Object.create(x.prototype)我們復制了x.prototype.z函數。參考


查看完整回答
反對 回復 2022-12-22
  • 1 回答
  • 0 關注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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