Why would Javascript `if…else if` not end with an `else`?

后端 未结 8 1889
误落风尘
误落风尘 2020-12-16 02:23

Here is a snippet of JavaScript code from a tutorial I was working with. I don’t understand why it doesn’t end with a final else clause; I thought that was a ru

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 02:53

    I thought it was always supposed to end with an "else"?

    The else block is optional. You can have if without else.

提交回复
热议问题