- Joined
- Oct 11, 2015
- Messages
- 424
- Reaction score
- 171
- First Language
- Dutch
- Primarily Uses
- RMMV
I know the difference between the two of 'em. But because Javascript is not a strict language and because other plugins may make mistakes (like putting '2' in the Actor.actorId instead of 2), using === may not always be a good idea unless it's purely for comparing your own variables?
I usually try to use as much === as possible, but only for my own variables. Is that good or bad?
.
Strings are a special case:
Of course for comparing objects. However, using === for strings can be dangerous if a string was created with String:
alert(new String('foo') === 'foo'); // falsealert(new String('foo') == 'foo'); // trueBecause you never know if the other person in some other plugin for some reason used a String() instead of a '' you can't use === for comparing strings that come from the RM-API either.
I usually try to use as much === as possible, but only for my own variables. Is that good or bad?
Strings are a special case:
Of course for comparing objects. However, using === for strings can be dangerous if a string was created with String:
alert(new String('foo') === 'foo'); // falsealert(new String('foo') == 'foo'); // trueBecause you never know if the other person in some other plugin for some reason used a String() instead of a '' you can't use === for comparing strings that come from the RM-API either.
Last edited by a moderator:
