I have:
function MyFunc() {
this.myString = "wooooo";
setTimeout(function () {
console.log("printing this.myString", this.myString);
}, 1000);
}
MyFunc();
If I run this inside node, I get the answer: printing this.myString undefined
(btw node --version gives v12.16.2
)
If I try this inside my console devtools in chrome browser, I get printing this.myString wooooo
(btw I have chrome 89.0.4389.90)
Can anybody explain me why this is different in nodejs and js? Why has it different behaviour?
Thank you