So I am trying to understand the this
keyword in javascript and inner functions. and I have an inner function with the this
keyword but it is returning "my hobby is undefined"
.
How can I make it return "my hobby is programming"
Here is what I tried and it did not work:
function practice() {
function close() {
console.log(`my hobby is ${this.hobby}`)
}
return close()
}
let person = {
hobby: "programming"
}
let binding = practice.bind(person)
console.log(binding())