Ad

Ad

Sunday, 4 May 2014

JavaScript Reserved Words

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

JavaScript Reserved Words

In JavaScript you cannot use these reserved words as variables, labels, or function names:
abstractargumentsbooleanbreakbyte
casecatchcharclassconst
continuedebuggerdefaultdeletedo
doubleelseenumevalexport
extendsfalsefinalfinallyfloat
forfunctiongotoifimplements
importininstanceofintinterface
letlongnativenewnull
packageprivateprotectedpublicreturn
shortstaticsuperswitchsynchronized
thisthrowthrowstransienttrue
trytypeofvarvoidvolatile
whilewithyield


JavaScript Objects, Properties, and Methods

You should also avoid using the name of JavaScript objects, properties, and methods:
ArrayDateevalfunctionhasOwnProperty
InfinityisFiniteisNaNisPrototypeOflength
MathNaNnameNumberObject
prototypeStringtoStringundefinedvalueOf


Java Reserved Words

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


Windows Reserved Words

JavaScript can be used outside HTML. It can be used as the programming language in many other applications.
In HTML you must (for portability you should) avoid using the name of HTML and Windows objects and properties:
alertallanchoranchorsarea
assignblurbuttoncheckboxclearInterval
clearTimeoutclientInformationcloseclosedconfirm
constructorcryptodecodeURIdecodeURIComponentdefaultStatus
documentelementelementsembedembeds
encodeURIencodeURIComponentescapeeventfileUpload
focusformformsframeinnerHeight
innerWidthlayerlayerslinklocation
mimeTypesnavigatenavigatorframesframeRate
hiddenhistoryimageimagesoffscreenBuffering
openopeneroptionouterHeightouterWidth
packagespageXOffsetpageYOffsetparentparseFloat
parseIntpasswordpkcs11pluginprompt
propertyIsEnumradioresetscreenXscreenY
scrollsecureselectselfsetInterval
setTimeoutstatussubmittainttext
textareatopunescapeuntaintwindow


HTML Event Handlers

In addition you should avoid using the name of HTML event handlers like these:
onbeforeunloadonblurondragdroponclickoncontextmenu
ondragdroponerroronfocusonkeydownonkeypress
onkeyuponmouseoveronloadonmouseuponmousedown
onresetonmousemoveonsubmitonmouseoutonunload

No comments:

Post a Comment