Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the usage and precautions of this

Shulou Source: shulou.com Published: 2022-06-02 10:28:43 10月04日 Update

What are the usage and precautions of this? in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.

This: represents an object. Is a reference to the object to which the function belongs.

Where the object calls the function where the this is located, the this represents the object and is the reference to the object.

When developing

When defining a function, if the object that invokes the function is used internally by the function, the object is represented by this.

This can also be used for calls between constructors.

Call format: this (actual parameter)

Follow the this object. Member properties and member methods are called (general methods)

The this object is followed by the () call to the constructor of the corresponding parameter in this class.

Note: calling the constructor with this must be defined on the first line of the constructor. Because the constructor is used for initialization, the initialization action must be performed. Otherwise, the compilation fails.

The answers to the questions about the usage and precautions of this are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Tags: Objects functions functions methods problems items notes representatives parameters that is members places more help answers easy easy one line content action Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux vpn Shulou Tech Info Huawei Docker