In JavaScript, you cannot use reserved words as variable names, 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 |
The following reserved words were removed from the ECMAScript 5/6 standard:
|
abstract |
boolean |
byte |
char |
|
double |
final |
float |
goto |
|
int |
long |
native |
short |
|
synchronized |
throws |
transient |
volatile |
|
Avoid using these words as variable names, as ECMAScript 5/6 is not fully supported in all browsers. |
You should also avoid using the names of JavaScript built-in objects, properties, and methods as variable names.
|
Array |
Date |
eval |
function |
|
hasOwnProperty |
Infinity |
isFinite |
isNaN |
|
isPrototypeOf |
length |
Math |
NaN |
|
name |
Number |
Object |
prototype |
|
String |
toString |
undefined |
valueOf |
JavaScript is frequently used alongside Java, so it’s best to avoid using Java object and property names as JavaScript identifiers.
|
getClass |
java |
JavaArray |
javaClass |
|
JavaObject |
JavaPackage |
JavaScript can be used as the programming language for various applications.
You should also avoid using the names of HTML and Window objects and their properties as identifiers.
|
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 |
Additionally, you should avoid using the names of all HTML event handlers as identifiers.
Examples:
|
onblur |
onclick |
onerror |
onfocus |
|
onkeydown |
onkeypress |
onkeyup |
onmouseover |
|
onload |
onmouseup |
onmousedown |
onsubmit |