JavaScript

JavaScript is a high-level, interpreted programming language that is widely used for web development. Initially designed as a client-side scripting language, it runs directly in web browsers, enabling dynamic and interactive user experiences. JavaScript can now be used for server-side development as well.

JavaScript Reserved Words

14 April 2025 | Category:

In JavaScript, reserved words are identifiers (like variable names or function names) that cannot be used because they are either part of the language syntax or reserved for future use.

Using these words as variable names or function names can lead to errors or unexpected behavior.


📌 1. Reserved Keywords (Used by JavaScript)

These are actively used in JavaScript syntax and must not be used as identifiers:

CategoryReserved Words
Control Flowif, else, switch, case, default
Loopsfor, while, do, break, continue
Declarationsvar, let, const, function, class, extends, super
Scopethis, return, yield
Error Handlingtry, catch, throw, finally
Imports & Exportsimport, export, from, as
Othersnew, delete, typeof, instanceof, void, in, with, await

📌 2. Future Reserved Words

These are reserved for future versions of JavaScript and should be avoided:

enum, implements, package, protected, interface, private, public, static

They may not throw an error now but can break your code in the future when these become official features.


📌 3. Reserved in Strict Mode

When using "use strict"; in your JavaScript (recommended), the following words become reserved:

let, yield, eval, arguments

Strict mode has stricter parsing and error handling and doesn’t allow reassigning or using these as identifiers.


📌 4. Literals (Also Reserved)

You cannot use the following JavaScript literals as identifiers:

null, true, false

These represent actual values in JavaScript and are not re-definable.


📌 5. Reserved Objects & Globals (Avoid Using as Variables)

Even though not strictly “reserved,” it’s a bad idea to use names of global objects or functions like:

Array, Object, Function, Number, String, Date, Math, JSON, RegExp, Promise, Set, Map, console, window, document

Using them as variables will override built-in features, which can break your app.


❌ Examples of Invalid Usage

let class = "MyClass"; // ❌ SyntaxError: Unexpected token 'class'

function return() { }   // ❌ Invalid function name

const new = 5;         // ❌ 'new' is reserved

✅ Tips to Avoid Reserved Word Errors

  • Stick to descriptive variable names.
  • Use linters like ESLint to catch these issues early.
  • Avoid using anything that “looks” like a JS keyword for your variables or functions.

🔍 Complete List of Reserved Words

You can check the full and up-to-date list of JavaScript reserved words in the ECMAScript specification.