Last active
February 23, 2016 14:00
-
-
Save nexpr/8e314de1f331e680be38 to your computer and use it in GitHub Desktop.
class 版の get set の継承
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var v = new class B extends class A { | |
| get test(){ | |
| console.log("parent getter") | |
| return this.xxx | |
| } | |
| set test(x){ | |
| console.log("parent setter") | |
| this.xxx = x | |
| } | |
| } { | |
| get test(){ | |
| console.log("child getter") | |
| return super.test | |
| } | |
| set test(x){ | |
| console.log("child setter") | |
| console.log(x) | |
| super.test = x | |
| } | |
| } | |
| console.log(v) | |
| // Object { } | |
| v.test = "tetete" | |
| // child setter | |
| // tetete | |
| // parent setter | |
| console.log(v) | |
| // Object { xxx: "tetete" } | |
| console.log(v.test) | |
| // child getter | |
| // parent getter | |
| // tetete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment