JavaScript keywords: the complete list (with reserved words)

By

Published · Updated

Tagged: JavaScript

JavaScript keywords and reserved words you cannot use as variable names, including await, class, const, let, and words reserved only in strict mode.

JavaScript keywords are the words the language keeps for its own syntax. The reserved ones are usually called reserved words. You cannot use a reserved word as a variable name, a function name, or a class name.

The tables below are the full set. After that, the words that surprise people (let, yield, await, static) get a short note each.

Reserved everywhere

These cannot be names anywhere in a JavaScript file.

Keyword What it is for
break Leave a loop or a switch
case One branch of a switch
catch Handle a thrown value
class Declare a class
const A binding you do not reassign
continue Skip to the next loop turn
debugger Pause when a debugger is attached
default The fallback branch of a switch
delete Remove a property
do The start of a do...while loop
else The other branch of an if
export Send a binding out of a module
extends Set the parent of a class
false The boolean false
finally Code that runs after try / catch
for A for loop
function Declare a function
if A condition
import Bring a binding in from a module
in Test whether an object has a property
instanceof Test an object’s prototype
new Construct an object
null The null value
return Leave a function, optionally with a value
super The parent constructor or its methods
switch Pick a branch by value
this The current object
throw Raise an exception
true The boolean true
try Wrap code that might throw
typeof A string naming the type of a value
var A function-scoped variable
void Evaluate an expression and get undefined
while A loop that tests the condition first
with Extend the scope chain

with is on this list even though strict mode rejects the statement. The word itself is reserved in every mode.

Reserved only in some code

Keyword Where it is reserved What it is for
let Strict mode, and inside let, const, and class declarations A block-scoped binding
static Strict mode A class member that lives on the constructor
yield Strict mode, and inside a generator Pause a generator and hand a value out
await Modules, and the body of an async function Pause an async function until a promise settles
enum Everywhere Reserved for a future enum syntax. JavaScript has none today
implements Strict mode Reserved, with no syntax of its own
interface Strict mode Reserved, with no syntax of its own
package Strict mode Reserved, with no syntax of its own
private Strict mode Reserved. Private fields use a # name, not this word
protected Strict mode Reserved, with no syntax of its own
public Strict mode Reserved, with no syntax of its own

enum is reserved in case a future edition of the language adds enums. You still cannot use it as a name.

Contextual keywords

These look like keywords in one spot and like ordinary names everywhere else. You can still declare a variable with these names.

Word Where the parser treats it as syntax
async Before an async function
as In import * as name
from In an import or export
get On a getter method
of In a for...of loop
set On a setter method

arguments and eval are not keywords. Strict mode still refuses them as binding names.

A few names from ES1 through ES3 show up on old lists: abstract, boolean, byte, char, double, final, float, goto, int, long, native, short, synchronized, throws, transient, volatile. Current JavaScript does not reserve them. const int = 1 is legal, including inside a module.

What happens if you use one?

You get a syntax error before your code even runs:

const class = 'physics'
// SyntaxError: Unexpected token 'class'

The parser sees class and expects a class declaration, not a variable name. The same happens with function names and parameter names.

Note that reserved words are only off-limits as identifiers. They work fine as property names, because there the context is never ambiguous:

const lesson = { class: 'physics', new: true }
lesson.class //'physics'

let

let declares a binding that belongs to the block, not to the whole function.

Outside strict mode, a sloppy script can still use it as a name:

var let = 1

Turn on strict mode, or move the file into a module, and that line is a syntax error. let is also reserved inside let, const, and class declarations even when the rest of the file is sloppy.

yield

yield pauses a generator and passes a value to the caller.

Like let, it is reserved in strict mode and tolerated as a name in old sloppy scripts. It is also reserved inside a generator function, because there it starts a yield expression.

await

await pauses an async function until a promise settles.

It is not reserved in every file. It is reserved in modules and inside async functions, which is almost everywhere you write JavaScript today. A classic script that is not a module can still use await as a name. I would not. The moment that file becomes a module, the name breaks.

static

static marks a method or field that lives on the constructor, not on each instance.

It is reserved in strict mode. Class bodies are always strict, so inside a class the word is always the keyword. In a sloppy script, outside a class, var static = 1 still parses.

Words reserved for the future

implements, interface, package, private, protected, and public are reserved only in strict mode. In old-style sloppy code this is legal:

var private = 'my secret'

Turn on strict mode, and the same line becomes a syntax error:

'use strict'
var private = 'my secret'
// SyntaxError: Unexpected strict mode reserved word

ES modules and class bodies are always in strict mode, so in modern code treat these words as fully reserved.

private on that list is not how you write a private field. Private fields use a hash name, as in #secret. The identifier private has no syntax of its own.

What about using?

The Explicit Resource Management proposal adds using and await using declarations, for resources that need cleanup when you are done with them. It is a finished TC39 proposal scheduled for ES2027, and it already runs in Chrome 134+, Firefox 141+ and Node 24+.

using is not a reserved word. It is a contextual keyword, like async or of. The parser treats it as a keyword only at the start of a declaration, so you can still name a variable using:

const using = 'still legal'

Pick another name anyway. Now that using file = open(path) is a declaration, a variable called using will confuse everyone reading your code.

One realistic way reserved words bite you: you write let public = true in a quick script, it works, then you move that code into a module and it breaks with a strict mode error. The fix is to pick a different name from the start, something like isPublic. Avoiding every word on this list, in any mode, keeps your code portable.

Want me to talk about your product? You can sponsor this site.

Related posts about js: