I'd like to use this
to referring to the class properties while instead is referring to the function itself. How can I do?
class Person {
isWalking = false
steps = 10
walk() {
this.isWalking = setInterval(function () {
if (this.steps <= 1) {
clearInterval(this.isWalking)
this.isWalking = false
}
--this.steps
console.log(this.steps)
}, 1000)
}
}