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

后端 未结 8 1306
情深已故
情深已故 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:13

    Who is interested in the performance gain of variable === undefined, may take a look here, but it seems to be a chrome optimization only.

    • http://jsperf.com/type-of-undefined-vs-undefined/30
    • http://jsperf.com/type-of-undefined-vs-undefined

提交回复
热议问题