JavaScript/super

来自康健生活
Kangkk​(留言 | 贡献)2022年7月10日 (日) 17:07的版本 (创建页面,内容为“== 引言 == == constructor == {{hcdiff|head=语法糖|output=<syntaxhighlight lang="javascript"> function Point(x, y) { this.x = x; this.y = y; } Point.prototyp…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

引言

constructor

语法糖
function Point(x, y) {
  this.x = x;
  this.y = y;
}
Point.prototype.toString = function () {
  return `(${this.x},${this.y})`;
}
class Point {
  constructor(x ,y) {
    this.x = x;
    this.y = y;
  }
  toString() {
    return `(${this.x},${this.y})`;
  }
}

super

模板:Leftrightflex


模板:Leftrightflex