i see this combination of exclamation points used occasionally in the default scripts; what exactly do two exclamation marks side by side mean?
!!
Learning Javascriptit's just converting something to a boolean value.
! means not - it converts it to a boolean and negates it
!! is the equivalent of "not not" - it converts it to a boolean but doesn't negate it
! means not - it converts it to a boolean and negates it
!! is the equivalent of "not not" - it converts it to a boolean but doesn't negate it
so !! is a short-hand way of performing an equation like this?
Code:
boolean = !boolean;
That's correct, however as stated above, ! means not, so doing something like this..
Hopefully that makes sense, 😀
Code:
console.log( $gamePlayer ); // this would log the game player object in the console.
console.log( !$gamePlayer ); // this would log false in the console, because the game player does exist, if the $gamePlayer data was set to undefined, or null, it would return true though.
console.log( !!$gamePlayer ); // this would return true in the console, because it's checking if the game player does not, not exist.
Hopefully that makes sense, 😀
that all makes perfect sense; thank you both very much for your help!
Original thread: https://forums.rpgmakerweb.com/threads/84304/