variable === undefined vs. typeof variable === “undefined”

后端 未结 8 1351
情深已故
情深已故 2020-11-22 14:43

The jQuery Core Style Guidelines suggest two different ways to check whether a variable is defined.

  • Global Variables: typeof variable === "undefined&
8条回答
  •  无人共我
    2020-11-22 15:11

    typeof a === 'undefined' is faster then a === 'undefined' by about 2 times on node v6.9.1.

提交回复
热议问题