JavaScript Reserved Words
- Previous Page JS Performance
- Next Page JS Version
JavaScript Reserved Words
In JavaScript, you cannot use these keywords as variable names, identifiers, or function names:
abstract | arguments | await* | 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 |
Keywords marked with an asterisk are new in ECMAScript 5 and 6.
You can find more information on JS VersionRead more about different JavaScript versions here.
Removed keywords
The following keywords have been removed from the ECMAScript 5/6 standard:
abstract | boolean | byte | char |
double | final | float | goto |
int | long | native | short |
synchronized | throws | transient | volatile |
Please do not use these reserved words as variable names. Not all browsers fully support ECMAScript 5/6.
JavaScript objects, properties, and methods
You should also avoid using the names of JavaScript built-in objects, properties, and methods:
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 certain Java objects and properties as JavaScript identifiers:
getClass | java | JavaArray | javaClass |
JavaObject | JavaPackage |
Other reserved words
JavaScript can be used as a programming language in many applications.
You should also avoid using the names of HTML and Window objects and properties:
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 Handler
In addition, you should avoid using all the names of HTML event handlers.
For example:
onblur | onclick | onerror | onfocus |
onkeydown | onkeypress | onkeyup | onmouseover |
onload | onmouseup | onmousedown | onsubmit |
- Previous Page JS Performance
- Next Page JS Version