Underscore prefixes in vars

l3m35

Veteran
Veteran
Joined
Nov 24, 2017
Messages
53
Reaction score
15
First Language
PT-BR
Primarily Uses
RMMV
This:



Both .level and ._level are accessible, and as I just read here, it's not a Javascript thing, just a convention (that I don't know why it's used in this case). My doubt is: is there any difference using one or another?

Like: $gameParty.members()[0]._level

Or it should be: $gameParty.members()[0].level

?
 

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,623
Reaction score
1,439
First Language
French
Primarily Uses
RMMV
logicly you use _props, for direct ._props with valur reference, and .props for obj or function or getter .
each one these tastes.
 

LTN Games

Indie Studio
Veteran
Joined
Jun 25, 2015
Messages
704
Reaction score
631
First Language
English
Primarily Uses
RMMV
Pretty sure MV uses _ for var names when they are meant to be private or internal only. Meaning avoid using them outside the class they are contained in.
It should be easily avoidable for most classes as they provide alot of functions and public variables already.

So using .level instead of ._level is advised for best practices and keeping things consistent with MV's style.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,868
Messages
1,017,066
Members
137,576
Latest member
SadaSoda
Top