class Foo {
constructor () {
}
get (fn) {
fn()
}
}
var obj = new Foo()
obj.get(function () {
console.log(this)
})
class Foo {
constructor (name) {
this.name = 'Шрек'
}
get (fn) {
fn
}
}
var obj = new Foo()
obj.get(function () {
console.log(this.name)
}.call(obj))