Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use this alone

Shulou Source: shulou.com Published: 2022-06-01 03:30:04 10月01日 Update

In this article, the editor introduces "how to use this alone" in detail, the content is detailed, the steps are clear, and the details are handled properly. I hope this "how to use this alone" article can help you solve your doubts.

This in the method

In object methods, this points to the object that calls its method.

The object to which the fullName method belongs is person.

Case study

FullName: function () {

Return this.firstName + "" + this.lastName

}

Using this alone

Using this alone, it points to a global (Global) object.

In the browser, window means that the global object is [object Window]:

Case study

Var x = this

In strict mode, this also points to a Global object if used alone.

Case study

"use strict"

Var x = this

After reading this, the article "how to use this alone" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself to understand it. If you want to know more about related articles, welcome to follow the industry information channel.

Tags: Object method global instance point article content that is proper ideas location ownership new knowledge more patterns steps browsers knowledge knowledge points articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Xiaomi MySQL Huawei Apple