In this scenario I get this
to be undefined
:
function outside(callback){
callback()
}
var obj = {
myProperty: 'john',
f1: function() {
outside(this.f2)
},
f2: function() {
console.log('-->', this.myProperty)
}
}
obj.f1()
How to fix it so this
in f2
will refer to obj
?