1.JavaScript reserved Keywords
In JavaScript, some identifiers are reserved keywords and cannot be used as variable names or function names.
1.1 JavaScript Standard
All modern browsers fully support ECMAScript 3 (the third edition of Es3,javascript, starting from 1999).
ECMAScript 4 (ES4) failed.
ECMAScript 5 (released in es5,2009), is the latest official version of JavaScript.
As time went on, we began to see that all modern browsers have fully supported ES5.
1.2JavaScript reserved Keywords
The reserved keyword for Javascript cannot be used as a variable, tag, or function name. Some reserved keywords are used as Javascript extensions later.
Abstract |
Arguments |
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* |
Inch |
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 keyword of the tag is newly added in ECMAScript5.
1.3 JavaScript objects, properties, and methods
You should also avoid using JavaScript's built-in object, properties, and method names as a variable or function name for javascript:
Array |
Date |
Eval |
function |
hasOwnProperty |
Infinity |
Isfinite |
IsNaN |
isPrototypeOf |
Length |
Math |
NaN |
Name |
Number |
Object |
Prototype |
String |
Tostring |
Undefined |
ValueOf
|
1.4Java reserved Keywords
GetClass |
Java |
Javaarray |
Javaclass |
Javaobject |
Javapackage |
1.5Windows reserved Keywords
JavaScript can be used outside the HTML. It can be used as a programming language in many other applications.
In HTML, you must (you should do the same for portability) avoid using the names of HTML and Windows objects and properties as Javascript variables and function names:
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 |
1.6HTML Event Handle
In addition, you should avoid using the name of the HTML event handle as a variable and function name for Javascript.
Instance:
Onblur |
OnClick |
OnError |
onfocus |
OnKeyDown |
onkeypress |
OnKeyUp |
onmouseover |
OnLoad |
OnMouseUp |
OnMouseDown |
OnSubmit |
1.6 Non-standard JavaScript
In addition to preserving keywords, there are also non-standard keywords in JavaScript implementations.
An instance is a const keyword that defines a variable. Some JavaScript engines treat const as a synonym for Var. Other engines Consider Const as the definition of a read-only variable.
Const is an extension of JavaScript. The JavaScript engine supports it in Firefox and Chrome. But it is not part of the JavaScript standard ES3 or ES5. Recommendation: Do not use it .
JavaScript reserved Keywords