1. This refers to the problem. In general, this eventually refers to the object that called it
2. In a global scope or normal function, this refers to the global object Window.
3. Who calls this in a method call points to whom
Constructor this refers to an instance of the constructor
<body> <button> click </button> <script> // this points to the problem. In a global scope or normal function, this points to the global object window (this in a timer points to window) console.log(this); //window function fn() { console.log(this); //window } window.fn(); window.setTimeout(function() { console.log(this); //window }, 1000); Var o = {sayHi: function() {console.log(this); // This refers to the object o}} o.sayhi (); var btn = document.querySelector('button'); btn.onclick = function() { console.log(this); } btn.adDeventListener ('click', function() {console.log(this); Function Fun() {console.log(this); // This refers to the BTN button object. } var fun = new fun (); </script> </body>Copy the code