Skip to content

Instantly share code, notes, and snippets.

@nexpr
Last active February 23, 2016 14:00
Show Gist options
  • Select an option

  • Save nexpr/8e314de1f331e680be38 to your computer and use it in GitHub Desktop.

Select an option

Save nexpr/8e314de1f331e680be38 to your computer and use it in GitHub Desktop.
class 版の get set の継承
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