+ 4

How is this code used in JavaScript? if(true){so so ans so}

Meaning of the if(true) statement

5th Sep 2019, 3:41 PM
Francis Woli
Francis Woli - avatar
9 ответов
+ 3
it means if the condition is true.......... I now get it
7th Nov 2020, 6:56 PM
Francis Woli
Francis Woli - avatar
+ 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.
5th Sep 2019, 3:42 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
Prometheus 🇸🇬 can you give an example?
5th Sep 2019, 3:46 PM
Francis Woli
Francis Woli - avatar
+ 2
If(condition){ statement } //if the condition is true, the statement is returned else an alternative
6th Sep 2019, 8:44 AM
Mirembe Matia
Mirembe Matia - avatar
+ 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(); }
5th Sep 2019, 3:49 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Prometheus 🇸🇬 I want an instance where the statement if(true) is used
5th Sep 2019, 5:37 PM
Francis Woli
Francis Woli - avatar
+ 1
If (age >= 16) { //A callback function } else { alert (You are not old enough!); return; };
5th Sep 2019, 9:45 PM
Anthony Johnson
Anthony Johnson - avatar
+ 1
You could also use a (if if else ) statement if you have to state that it does return true
5th Sep 2019, 9:49 PM
Anthony Johnson
Anthony Johnson - avatar
+ 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
7th Sep 2019, 6:41 AM
kay cruz
kay cruz - avatar