The use of$(this), which is jQuery’s syntax for thethiskeyword in JavaScript, is used inside an anonymous function, and the anonymous function is executed in the button’s click () method. The reason(this)isboundtothebuttonobjectisbecausethejQuerylibrarybinds(this)isboundtothebuttonobjectisbeca...
Specification ECMAScript® 2026 Language Specification # sec-this-keyword 浏览器兼容性 参见 严格模式 globalThisHelp improve MDN Was this page helpful to you? YesNoLearn how to contribute. This page was last modified on 2025年4月13日 by MDN contributors. View this page on GitHub • Report ...
The very first thing to understand when we're talking about this-keyword is really understand what's the purpose of the this-keyword is, or why we even have this-keyword in JavaScript. What the this-keyword allows us to do, is it allows us to reuse functions with different contexts, or...
In JavaScript,thiskeyword refers to theobjectwhere it is called. 1. this Inside Global Scope Whenthisis used alone,thisrefers to the global object (windowobject in browsers). For example, leta =this;console.log(a);// Window {}this.name ='Sarah';console.log(window.name);// Sarah Run C...
The very first thing to understand when we're talking about this-keyword is really understand what's the purpose of the this-keyword is, or why we even have this-keyword in JavaScript. What the this-keyword allows us to do, is it allows us to reuse functions with different contexts, or...
The "this" is special keyword in JavaScript. It is used to refer to the object on which a method is being invoked. So what is the the value of "this" in a given context ? We will state some basic steps. Do not worry if you do not understand it. Just read it once. We will re...
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call bind Thebind()method creates a new function that, when called, has itsthiskeyword set to the provided value, with a given sequence of arguments preceding any provided when the new function is called....
http://www.ruanyifeng.com/blog/2010/04/using_this_keyword_in_javascript.html 分情况讨论。 情况一:纯粹的函数调用 这是函数的最通常用法,属于全局性调用,因此this就代表全局对象Global。 var x = 1; function test(){ this.x = 0; ...
In JavaScript, thethiskeyword refers to anobject. Thethiskeyword refers todifferent objectsdepending on how it is used: In an object method,thisrefers to theobject. Alone,thisrefers to theglobal object. In a function,thisrefers to theglobal object. ...
Learn how the JavaScript “this” keyword behaves inside of function declarations and expressions, even when nested 10 levels deep. In the article: The JavaScript “this” Keyword Deep Dive: An Overview, we discussed a number of scenarios in which the JavaScript “this” Keyword has different me...