[removed] || instead of IF statement - is this legal and cross browser valid?

后端 未结 10 970
忘掉有多难
忘掉有多难 2020-12-23 20:43

It seems that:

if (typeof a == \'undefined\') {
    a = 0;
}

and

(typeof a != \'undefined\') || (a = 0)

h

10条回答
  •  感动是毒
    2020-12-23 21:16

    I hated "|| instead of IF" for years.

    I finally got used to it and now I love it.

    I also like using && in the same way.

    I've found it is much easier to read others terse code if you adopt terse practices yourself.

    Totally understand where others are coming from though. Been there myself.

提交回复
热议问题