I`m using VS code and chrome debugger extension . The code below is executed without errors and produces the expected result, however i see that 'this' is undefined in WATCH section.
class Q {
constructor() {
this.arr = [1,2,3]
}
log(e) {
console.log(e)
}
test() {
this.arr.forEach(e => {
this.log(e); // this is undefined when debugging
})
}
}
const f = new Q().test()
what am I doing wrong?
To avoid conflicts with the this
JavaScript keyword, TypeScript renames this
into _this
when transpiled. Try watching for _this
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With