, call super - , :
function Foo() {
Bar.call(this)
}
class Foo extends Bar {
constructor() {
super()
}
}
( Bar Foo), super call .
super , call Function.
super . , :
class Bar {
constructor() {
}
bang() {
console.log('bang')
}
}
class Foo extends Bar {
constructor() {
super()
}
bang() {
super.bang()
}
}
call, , Function, this. .
function baz() { console.log(this.bar) }
baz()
baz.call({ bar: 'foo' })
. , this (global, window). this undefined, baz . call this, .