Discord
Login
Community
DARK THEME

what is "this." command used for in microstudio?

what is "this." command used for in microstudio? i saw many people using it and i never got what it is for.

It's a reference to the instance of class or object, that was used to call the member function. It's the same as with any other OOP language, like C++ or Java.

The word "this" is not in the MicroScript specification, but it can be used.

It will usually be used in a class and it works the same way as in JavaScript (except that in JavaScript it is a necessary word to refer inside a class to a field of the same class or to another method of the same class).

Why use it if it is not necessary - sometimes you port code from JavaScript for example and do not need to remove this word.

You may also be used to using this word - because you wrote in JavaScript before.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community