📜  if 和 else 简写 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:45.554000             🧑  作者: Mango

代码示例1
//Long version  
let points = 70;   
let result;   
if(marks >= 50){  
    result = 'Pass';   
}else{  
    result = 'Fail';   
}

//Shorthand  
let points = 70;   
let result = marks >= 50 ? 'Pass' : 'Fail';