JavaScript Reserved Words

By | August 27, 2022

In JavaScript you cannot use these reserved words as variables, labels, or function names:

abstractargumentsawait*boolean
breakbytecasecatch
charclass*constcontinue
debuggerdefaultdeletedo
doubleelseenum*eval
export*extends*falsefinal
finallyfloatforfunction
gotoifimplementsimport*
ininstanceofintinterface
let*longnativenew
nullpackageprivateprotected
publicreturnshortstatic
super*switchsynchronizedthis
throwthrowstransienttrue
trytypeofvarvoid
volatilewhilewithyield

Words marked with* are new in ECMAScript 5 and 6.

You can read more about the different JavaScript versions in the chapter JS Versions.

Removed Reserved Words

The following reserved words have been removed from the ECMAScript 5/6 standard:

abstractbooleanbytechar
doublefinalfloatgoto
intlongnativeshort
synchronizedthrowstransientvolatile

Do not use these words as variables. ECMAScript 5/6 does not have full support in all browsers.

JavaScript Objects, Properties, and Methods

You should also avoid using the name of JavaScript built-in objects, properties, and methods:

ArrayDateevalfunction
hasOwnPropertyInfinityisFiniteisNaN
isPrototypeOflengthMathNaN
nameNumberObjectprototype
StringtoStringundefinedvalueOf

Java Reserved Words

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

getClassjavaJavaArrayjavaClass
JavaObjectJavaPackage

Other Reserved Words

JavaScript can be used as the programming language in many applications.You should also avoid using the name of HTML and Window objects and properties:

alertallanchoranchors
areaassignblurbutton
checkboxclearIntervalclearTimeoutclientInformation
closeclosedconfirmconstructor
cryptodecodeURIdecodeURIComponentdefaultStatus
documentelementelementsembed
embedsencodeURIencodeURIComponentescape
eventfileUploadfocusform
formsframeinnerHeightinnerWidth
layerlayerslinklocation
mimeTypesnavigatenavigatorframes
frameRatehiddenhistoryimage
imagesoffscreenBufferingopenopener
optionouterHeightouterWidthpackages
pageXOffsetpageYOffsetparentparseFloat
parseIntpasswordpkcs11plugin
promptpropertyIsEnumradioreset
screenXscreenYscrollsecure
selectselfsetIntervalsetTimeout
statussubmittainttext
textareatopunescapeuntaint
window

HTML Event Handlers

In addition you should avoid using the name of all HTML event handlers.Examples:

onbluronclickonerroronfocus
onkeydownonkeypressonkeyuponmouseover
onloadonmouseuponmousedownonsubmit

Leave a Reply

Your email address will not be published. Required fields are marked *