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ù)組并將其分配給類字段值嗎?
數(shù)組解構(gòu)并分配給類字段值?
胡說叔叔
2023-08-24 17:52:23