Reserved Words - Object-Oriented JavaScript Second Edition (2013)

Object-Oriented JavaScript Second Edition (2013)

Appendix A. Reserved Words

This appendix provides two lists of reserved keywords as defined in ECMAScript 5 (ES5). The first one is the current list of words, and the second is the list of words reserved for future implementations.

There's also a list of words that are no longer reserved, although they used to be in ES3.

You cannot use reserved words as variable names:

var break = 1; // syntax error

If you use these words as object properties, you have to quote them:

var o = {break: 1}; // OK in many browsers, error in IE

var o = {"break": 1}; // Always OK

alert(o.break); // error in IE

alert(o["break"]); // OK

Keywords

The list of words currently reserved in ES5 is as follows:

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

These keywords are not currently used, but are reserved for future versions of the language.

· class

· const

· enum

· export

· extends

· implements

· import

· interface

· let

· package

· private

· protected

· public

· static

· super

· yield

Previously reserved words

These words are no longer reserved starting with ES5, but best to stay away for the sake of older browsers.

· abstract

· boolean

· byte

· char

· double

· final

· float

· goto

· int

· long

· native

· short

· synchronized

· throws

· transient

· volatile