js中if条件这种写法有什么好处?

小程序 文章 2020-09-07 16:21 440 0 全屏看文

AI助手支持GPT4.0

js中if条件这种写法有什么好处?What are the benefits of writing if conditions in js?

js中if条件这种写法有什么好处?
  functionA(a){    if((a || null) != null){  ...  }  }


中间a || null 这种写法有什么好处么。

直接(a)不就行了么


Function a (a) {if ((a | null)! = null) {...}} middle a | null has any advantages. Just (a) is OK

回答:

迷失的故渊:

如果a是true的话 表达式就是a a如果是false 就执行||后面的表达式 不知道你能不能明白

微喵网络:

防止没传a

stop eating:

没什么好不好的,能达到目的就行了

-EOF-

AI助手支持GPT4.0