Member-only story
6 Little Secrets of JavaScript To Help You Shine at Job Interviews
Oddities and secrets in JavaScript probably fewer people know
JavaScript isn’t easy to grasp.
Often it does something completely different than you might expect. Undefined
is a keyword… “I don’t think so, mister!”. This is just a preview of the knowledge you can gather and shine when you get asked about JavaScript. True experts know the details.
Many little things are worth knowing to overcome accidental errors and avoid hour-long debugging.
1. Undefined Can Be Defined
Deprecation Info 09/2022: During the long presence of this article, the JavaScript devs changed undefined to a non-writeable identifier. If you try to create a variable with the name of ‘undefined,’ you’ll get “Uncaught SyntaxError: Identifier ‘undefined’ has already been declared.”
Strange as it might be, undefined
is not a reserved word in JavaScript. Although it has a special meaning and is the only way to determine whether a variable is not defined: