「JavaScript/クラス」の版間の差分

削除された内容 追加された内容
Ef3 (トーク | 投稿記録)
タグ: 2017年版ソースエディター
Ef3 (トーク | 投稿記録)
→‎ES6 の class を使ったコードと相当するES5のコード: Complex.prototype.csub = function(n) { return new Complex(this.real - n.real, this.imag - n.imag) }
タグ: 2017年版ソースエディター
214 行
toString(){ return `${this.real}+${this.imag}i` },
cadd(n){ return new Complex(this.real + n.real, this.imag + n.imag) },
csub(n){ return new Complex(this.real - n.real, this.imag - n.imag) },
})
Complex.prototype.csub = csubfunction(n) { return new Complex(this.real - n.real, this.imag - n.imag) },
let a = new Complex(1, 1)
let b = new Complex(2, 3)