第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

數(shù)組解構(gòu)并分配給類字段值?

數(shù)組解構(gòu)并分配給類字段值?

胡說叔叔 2023-08-24 17:52:23
class ALU {  constructor (x, y) {    this.zx = '0' // Zero the x input    this.nx = '0' // Negate the x input    this.zy = '0' // Zero the y input    this.ny = '0' // Negate the y input    this.f = '0' // Function code: 1 for Add, 0 for And    this.no = '0' // Negate the output  }  ...  setControlBits (controlBits) {    this.zx = controlBits[0]    this.nx = controlBits[1]    this.zy = controlBits[2]    this.ny = controlBits[3]    this.f = controlBits[4]    this.no = controlBits[5]  }  ...}如何簡潔地編寫這段代碼?就像我們可以解構(gòu)數(shù)組并將其分配給類字段值嗎?
查看完整描述

1 回答

?
九州編程

TA貢獻1785條經(jīng)驗 獲得超4個贊

試試這個。


function Foo(list) {

    [this.x, this.y] = list;

}


foo = new Foo([1, 2]);


console.log(foo.x);

console.log(foo.y);


查看完整回答
反對 回復(fù) 2023-08-24
  • 1 回答
  • 0 關(guān)注
  • 159 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號