Skip to content

Comment on JS performance: try / catch versus checking for undefined

Comments

Worth noting that `undefined` is a variable, and not a keyword.

   undefined = 1;
   >>> 1
   null = 1;
   >>> ReferenceError: invalid assignment left-hand side
It looks like Chrome and Firefox no longer let you assign to window.undefined any, but I'm not sure is IE has the same restrictions. The correct way to check for undefined is via `typeof`.
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.