Please tell me the behaviour of this in both situations. Why one shows 'window' and the other 'object'. Though they are called in the same manner by callback.
CASE: 1
let army = {
minAge: 18,
maxAge: 27,
canJoin(user) {
console.log(this);
}
};
function karan(callback){
callback();
}
karan(army.canJoin);
Result is WINDOW OBJECT
CASE: 2
let army = {
minAge: 18,
maxAge: 27,
canJoin(user) {
console.log(this);
}
};
function karan(callback){
callback();
}
karan( () => army.canJoin());
RESULT: THE OBJECT