Reputation: 99
x === false ? true: false;
what doesn't above JavaScript mean? is it if x is equal to false then set x to true or else set x to false?
Upvotes: 0
Views: 63
Reputation: 6949
It's called the ternary operator. Learn more about it here
or in long hand
if (x === false)
{
return true;
}
else
{
return false;
}
Upvotes: 0
Reputation: 2646
x === false ? true: false;
When x is equal and of the same type(boolean) then the statement is true else statement is false.
Written longhand would be
if(x === false){
return true;
}else{
return false;
}
Upvotes: 1
Reputation: 7501
That resolves to true
if x
is strictly equal to false
, and false
otherwise. No value is set for x
.
Upvotes: 3