JavaScript Reserved Words

In JavaScript, some identifiers are reserved keywords and cannot be used as variable or function names.

JavaScript Standards

All modern browsers fully support ECMAScript 3 (ES3, the third version of JavaScript, starting in 1999).

ECMAScript 4 (ES4) failed.

ECMAScript 5 (ES5, released in 2009) is the latest official version of JavaScript.

Over time, we started to see that all modern browsers have fully supported ES5.

JavaScript Reserved Words

Javascript reserved keywords cannot be used as variable, label, or function names. Some reserved keywords are used as Javascript extensions in the future.

abstract arguments boolean break byte
case catch char class* const
continue debugger default delete do
double else enum* eval export*
extends* false final finally float
for function goto if implements
import* in instanceof int interface
let long native new null
package private protected public return
short static super* switch synchronized
this throw throws transient true
try typeof var void volatile
while with yield

Words stamped with* are new in ECMAScript5

JavaScript Objects, Properties, and Methods

You should also avoid using JavaScript built-in object, property, and method names as JavaScript variable or function names:

Array Date eval function hasOwnProperty
Infinity isFinite isNaN isPrototypeOf length
Math NaN name Number Object
prototype String toString undefined valueOf

Java Reserved Words

JavaScript is often used with Java. You should avoid using some Java objects and properties as JavaScript identifiers:

getClass java JavaArray javaClass JavaObject JavaPackage

Windows Reserved Words

JavaScript can be used outside of HTML. It can be used as a programming language in many other applications.

In HTML, you must (for portability, you should do this) to avoid using HTML and Windows object and property names as Javascript variables and function names:

alert all anchor anchors area
assign blur button checkbox clearInterval
clearTimeout clientInformation close closed confirm
constructor crypto decodeURI decodeURIComponent defaultStatus
document element elements embed embeds
encodeURI encodeURIComponent escape event fileUpload
focus form forms frame innerHeight
innerWidth layer layers link location
mimeTypes navigate navigator frames frameRate
hidden history image images offscreenBuffering
open opener option outerHeight outerWidth
packages pageXOffset pageYOffset parent parseFloat
parseInt password pkcs11 plugin prompt
propertyIsEnum radio reset screenX screenY
scroll secure select self setInterval
setTimeout status submit taint text
textarea top unescape untaint window

HTML Event Handlers

In addition, you should avoid using the names of HTML event handlers as variables and function names in Javascript.


onblur onclick onerror onfocus
onkeydown onkeypress onkeyup onmouseover
onload onmouseup onmousedown onsubmit

In addition to reserved keywords, there are also some non-standard keywords in JavaScript implementations.

An example is the const keyword, which is used to define variables. Some JavaScript engines use const as a synonym for var. Other engines treat const as the definition of a read-only variable.

Const is an extension of JavaScript. The JavaScript engine supports it for use in Firefox and Chrome. But it's not JavaScript standard ES3 Or part of ES5. Suggestion: Don't use it .