I found out that if I trying to bind an arrow function it's not working.
Working:
const person = {
name: 'itzik',
age: 21,
get: () => person.name+person.age
}
function logname () {console.log(this.get)}
const logPerson = logname.bind (person)
logPerson()
But if I change the function logName
to an array function, like this:
const logName = () => console.log(this.get)
In this case, the this
will reference to the window object.
Why is that?