三元運算子 (Conditional operator)//三元運算子常常被做為if的簡潔寫法 function yourAge(age) { console.log(`(三元運算子)你的年齡大於18歲嗎? ${age > 18 ? "是" : "否"}`); } yourAge(33); //result: (...Tags: VanillaJS Apr 09, 2021 1 minute
while與do-while的差別var i = 5; //while是先判斷是否符合條件之後再執行裡面的語法 while (i > 5) { console.log(`while條件句裡的i變數目前是:${i}`); i--; } i = 5; //do-while則是先無條件執行一次裡面的語法之後,在來判斷是否符合條件...Tags: VanillaJS Apr 09, 2021 1 minute