JavaScript Reserved Words
In JavaScript, certain words are off-limits for use as variables, labels, 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 |
Words with a * were introduced in ECMAScript 5 and ECMAScript 6.
Learn more about various versions of JavaScript in the section JS Versions.
Removed Reserved Words
The ECMAScript 5/6 standard no longer includes the following reserved words:
abstract | boolean | byte | char |
double | final | float | goto |
int | long | native | short |
synchronized | throws | transient | volatile |
Avoid using these words as variables. Not all browsers fully support ECMAScript 5/6.
JavaScript Objects, Properties, and Methods
Avoid using the names of built-in objects, properties, and methods in JavaScript.
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 commonly used alongside Java. It's recommended to steer clear of certain Java objects and properties when naming things in JavaScript.
getClass | java | JavaArray | javaClass |
JavaObject | JavaPackage |
Other Reserved Words
JavaScript is a programming language that can be utilized in various applications.
Steer clear of mentioning HTML and Window objects and their properties in your code.
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 Handlers
Additionally, refrain from using the names of all HTML event handlers.
Examples:
onblur | onclick | onerror | onfocus |
onkeydown | onkeypress | onkeyup | onmouseover |
onload | onmouseup | onmousedown | onsubmit |