+ 4
How is this code used in JavaScript? if(true){so so ans so}
Meaning of the if(true) statement
9 Réponses
+ 3
it means if the condition is true.......... I now get it
+ 2
More often you see some conditional statement that can be true or false, depending on some conditions you specify.
They can allow you to selectively trigger events in manners you want.
+ 2
Prometheus 🇸🇬 can you give an example?
+ 2
If(condition){
statement
}
//if the condition is true, the statement is returned else an alternative
+ 1
Suppose you want to set age restrictions. You gather their user's age as "age".
To make sure the user is old enough like say, 16, then you cam do:
if (age<16){
allowAccess();
} else {
denyAccess();
}
+ 1
Prometheus 🇸🇬 I want an instance where the statement if(true) is used
+ 1
If (age >= 16) {
//A callback function
}
else {
alert (You are not old enough!);
return;
};
+ 1
You could also use a (if if else ) statement if you have to state that it does return true
+ 1
if conditional statements are by default true...else statements are used for ( if ) the if statement arent meet...it like a default to catch all things which arent met within the if statement...else if is another if statement that is also has conditionals who are by default set to true...operators such as !=, !==...etc. can be used to make conditionals false instead of true