Skip to content

Commit

Permalink
Update 05.子类继承父类方法并扩展自己的方法.html
Browse files Browse the repository at this point in the history
  • Loading branch information
zh1375543 authored Apr 15, 2024
1 parent 4877da1 commit a8f995e
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
console.log(this.x + this.y);
}
}
//子类继承父类加法方法,同时扩展减法方法
class Son extends Father {
constructor(x, y) {
super(x, y);
Expand All @@ -35,4 +36,4 @@
var son = new Son(4, 5)
son.subtract() //-1
son.sum() //9
</script>
</script>

0 comments on commit a8f995e

Please sign in to comment.