Try to summarize the usage of “this” with examples
Example 1
“handler” declared by error function here, that means the “this” is nothing, just same as outside the handler, thus the output is Window object
const handler = () => {
console.log(this);
};
btn1.addEventListener('click', handler);
Output
Window {parent: Window, opener: null, top: Window, length: 0, frames: Window, …}
#es6-in-depth #self-learning #javascript-tips #es6-js #self-taught #javascript