Property verbose .
, .
class Property {
v = 42
bar = () => {
return this.v
}
}
class Bound {
constructor() {
this.v = 43
this.bar = this.bar.bind(this)
}
bar() {
return this.v;
}
}
class Classic {
constructor() {
this.v = 44
}
bar() {
return this.v;
}
}
const allBars = [
new Property().bar,
new Bound().bar,
new Classic().bar
]
console.log([
allBars[0](),
allBars[1](),
allBars[2]()
])
// prints: [42, 43, undefined]
v undefined allBars, this bar , .