跳轉到內容

JavaScript/保留字/if

來自 Wikibooks,開放世界中的開放書籍
前一個:goto 保留字 下一個:implements

if關鍵字

[編輯 | 編輯原始碼]

if關鍵字啟動一個迴圈,該迴圈一直執行到滿足條件為止。

程式碼
  var result = 1;

  if (result%2 == 0) {
    console.log(result + " is an odd number");
  } else {
    console.log(result + " is an even number");
  }
返回以下內容
1 is an even number


前一個:goto 保留字 下一個:implements
華夏公益教科書