public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers

Garbage Collector: this vs global Variables

BMM Archive · July 15, 2026

Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: Garbage Collector: this vs global Variables
  • Original author: Eliaquim
  • Original date: January 19, 2020
  • Source thread: https://forums.rpgmakerweb.com/threads/garbage-collector-this-vs-global-variables.117429/
  • Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Learning Javascript

Summary

Hi people! I'm really trying to find out this information on the internet, but I can't find it. Since the keyword "this" let me access a property of a function outside of it, I want to know if the garbage collector behaves the same way as it behaves with global variables. So far as I know, javascript free the memory when an object or variable lost its reference.

Archived First Post

Hi people!
I'm really trying to find out this information on the internet, but I can't find it.

Since the keyword "this" let me access a property of a function outside of it, I want to know if the garbage collector behaves the same way as it behaves with global variables.
So far as I know, javascript free the memory when an object or variable lost its reference.
So in case of this keyword being used constantly, it behaves like a local variable that can be accessed outside the function? Or its behaves like a global variable(but not being global or local variable)?
My concern is performance.

So it's best for me to use this to change the property of a sprite for example:
this.carSprite.opacity = 100;

Or it's best for me to make a function that returns the opacity?

Function carSpriteOpacity(){
return 100;
}

Here is an example of information that tells me to use the "this" keyword to avoid using global variables.
But what confuses me is it's saying that it is different from the global variable, but it also can be accessed like a global variable outside of the function. So what I'm missing here?

Protected download

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download

Referenced Images / Attachments

Screenshot_20200119-144318.png
Screenshot_20200119-144318.png
Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#rpg-maker-archive#js-learning

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar