“onclick” and “this” in javascript
问题 I am confused: why with inline onlick, we have to write onclick="hello()", but in JS, we should write btn.onclick=hello or btn.addEventListener('click',hello); for regular function, why with inline onlick, "this" refers to window, but with js call, "this" refers to button. I don't understand last two buttons according to w3school, In a function, this refers to the global object. https://www.w3schools.com/js/js_this.asp In regular functions the this keyword represented the object that called