" if…else"结构在执行代码块之前先判断条件。
if(boolean_expression) { //statement(s) will execute if the Boolean expression is true }
if - 流程图

if - 示例
var num=5 if (num>0) { console.log("number is positive") }
成功执行上述代码后,将显示以下输出。
number is positive
上面的示例将打印" number is positive",因为if块指定的条件为true。