DEV Community

dmanias
dmanias

Posted on

What JavaScript variable names are valid in ES5

ECMAScript 5.1:

An Identifier is an IdentifierName that is not a ReservedWord.

The reserved groups are: keywords, future reserved words, null literals and boolean literals.

Keywords in Javascript are tokens with special meaning: break, case, catch, continue, debugger, default, delete, do, else, finally, for, function, if, in, instanceof, new, return, switch, this, throw, try, typeof, var, void, while, with.

Future reserved words are the tokens that may become keywords in a future revision of ECMAScript: class, const, enum, export, extends, import, and super. Some future reserved words only apply in strict mode: implements, interface, let, package, private, protected, public, static, yield.

Null literal: null.

Boolean literals: true, false.

An identifier must contain any character from the following Unicode categories “Uppercase letter (Lu)”, “Lowercase letter (Ll)”, “Titlecase letter (Lt)”, “Modifier letter (Lm)”, “Other letter (Lo)”, or “Letter number (Nl)”.

The article is a summary of the excellent article of Mathias Bynens:
https://mathiasbynens.be/notes/javascript-identifiers

Here is a validator for Javascript variables: https://mothereff.in/js-variables#%E0%B2%A0%5f%E0%B2%A0

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs