JavaScript reserved keywords



In JavaScript, some identifiers are reserved keywords and cannot be used as variable names 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 are starting to see that all modern browsers have full support for ES5.


JavaScript reserved keywords

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

abstractargumentsbooleanbreakbyte
casecatchcharclass*const
continuedebuggerdefaultdeletedo
doubleelse enum*evalexport*
extends*falsefinalfinallyfloat
forfunctiongotoifimplements
import*ininstanceofintinterface
letlongnativenewnull
packageprivateprotectedpublicreturn
shortstatic super*switchsynchronized
thisthrowthrowstransienttrue
trytypeofvarvoid volatile
whilewithyield

* The marked keyword is newly added in ECMAScript5.


JavaScript Objects, Properties, and Methods

You should also avoid using the names of built-in JavaScript objects, properties, and methods as JavaScript variable or function names:

ArrayDateevalfunctionhasOwnProperty
InfinityisFiniteisNaNisPrototypeOflength
MathNaNnameNumberObject
prototypeStringtoString undefinedvalueOf



##Java Reserved Keyword

JavaScript Regular Used with Java. There are some Java objects and properties that you should avoid using as JavaScript identifiers:

getClassjavaJavaArray javaClassJavaObjectJavaPackage



Windows Reserved Keywords

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

In HTML, you must (and for portability, you should) avoid using the names of HTML and Windows objects and properties as Javascript variable and function names:

alertallanchoranchorsarea
assignblurbuttoncheckboxclearInterval
clearTimeoutclientInformation closeclosedconfirm
constructorcryptodecodeURIdecodeURIComponentdefaultStatus
documentelementelementsembedembeds
encodeURIencodeURIComponentescapeeventfileUpload
focusformformsframeinnerHeight
innerWidthlayerlayerslinklocation
mimeTypesnavigatenavigator framesframeRate
hiddenhistoryimageimagesoffscreenBuffering
openopeneroptionouterHeightouterWidth
packagespageXOffsetpageYOffsetparentparseFloat
parseInt passwordpkcs11pluginprompt
propertyIsEnumradioresetscreenXscreenY
scrollsecureselectselfsetInterval
setTimeoutstatussubmittaint text
textareatopunescapeuntaintwindow



HTML event handler

In addition, you should also avoid using the name of the HTML event handler as the name of Javascript variables and functions .

Example:

##



Non-standard JavaScript

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

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

Const is a JavaScript extension. The JavaScript engine supports its use in Firefox and Chrome. But it's not the JavaScript standard ES3 or components of ES5. Recommendation: Do not use it.

onbluronclickonerroronfocus
onkeydownonkeypressonkeyuponmouseover
onloadonmouseuponmousedownonsubmit