「JavaScript/クラス」の版間の差分
削除された内容 追加された内容
→ES6 の class を使ったコードと相当するES5のコード: ES5の例をObject.assignを使う形に。 タグ: 2017年版ソースエディター |
→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 =
let a = new Complex(1, 1)
let b = new Complex(2, 3)
|