Home >Web Front-end >JS Tutorial >Javascript basic tutorial if conditional statement_basic knowledge
if is one of the commonly used syntaxes, its format is as follows
if(coditon) statement1 (else statement2)
Among them, coditon can be any expression, even a real Boolean value, because JavaScript will automatically convert it into a Boolean value.
If the condition execution result is true, statement1 will be executed. If the condition is false, the execution result statment2 will be executed. (If statement2 exists, else is not necessary.)
Each conditional statement can be a single line of code or a block of code. The following is a simple example