What is this in [removed] “var var1 = var1 || []”

后端 未结 8 2008
清歌不尽
清歌不尽 2021-02-15 11:43

I just want to increase my core javascript knowledge.

Sometimes I see this statement but I don\'t know what it does:

var var1 = var1 || [];
8条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-15 12:13

    Basically if var1 is NULL or false, var1 will be set to an empty array.

提交回复
热议问题