Question: how this works in javascript?
Answer: The JavaScript this keyword refers to the object it belongs to. It has different values depending on where it is used: ... In a function, this refers to the global object. In a function, in strict mode, this is undefined .