//ECMAScript2015: class
class A {
constructor (a, b) {
Object.assign (this, {a, b});
this._val = null;//暗黙に内部変数
}
get value () {
return this._val;
}
set value (val) {
this._val = val;
}
get clone () {
let {a, b} = this;
return new this.constructor (a, b);
}
static tool (...arg) {
return new this (...arg);
}
static toolsFunc () {
const func = {
cbFunc: function (a) { return a+a}
}
return func;
}
static option (key = null) {
const option = {
};
return key ? option[key]: {...option};
}
}
class B extends A {
//もし constructor が無い場合、以下が暗黙に実行される
// constructor(...args) { super(...args); }
constructor (a, b, c) {
super (a, b);//先に実行すること
this.c = c;
}
test () {
let a = super.clone;
}
}