JavaScript Standard
All modern browsers have fully supported ES5 (ECMAScript 5).
JavaScript reserved Keywords (keyword)
A reserved keyword (identifier) for Javascript cannot be used as a variable, label, or function name. Some reserved keywords are used as Javascript for later expansion.
Abstract |
Arguments |
Boolean |
Break |
Byte |
Case |
Catch |
Char |
class* |
Const |
Continue |
Debugger |
Default |
Delete |
Todo |
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 keyword for the tag is newly added in ECMAScript5.
JavaScript objects, properties, and methods
You should also avoid using JavaScript-built names of objects, properties, and methods 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 |
Java reserved Keywords
JavaScript is often used in conjunction with Java. You should avoid using some Java objects and properties as JavaScript identifiers:
GetClass |
Java |
Javaarray |
Javaclass |
Javaobject |
Javapackage |
Windows reserved Keywords (reserved word)
JavaScript can be used outside of HTML. It can be used as a programming language in many other applications.
In HTML, you must (you should also do this 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 |
HTML Event Handle
In addition, you should avoid using the name of an HTML event handle as a Javascript variable and function name.
Instance:
Onblur |
OnClick |
OnError |
onfocus |
OnKeyDown |
onkeypress |
OnKeyUp |
onmouseover |
OnLoad |
OnMouseUp |
OnMouseDown |
OnSubmit |
Non-standard JavaScript
In addition to reserved keywords, there are some non-standard keywords in the JavaScript implementation.
One instance is the Const keyword, which is used to define variables. Some JavaScript engines treat const as synonymous with Var. Other engines define the const as 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 JavaScript standard ES3 or ES5. Recommendation: Do not use it.
Copy Code code as follows:
Google results:
Note: If you use a keyword as a variable or function name, you may get an error message such as "Identifier expected" (which should have identifiers, expected identifiers).
Note: If you use a reserved word as a variable or function name, you may not receive any error messages unless the future browser implements the reserved word. When the browser implements it, the word is treated as a keyword, so a keyword error occurs.
Here's a description of the JavaScript language identifier
Identifiers are names that are given to variables, functions, objects, and so on. The letter that makes up the identifier is a certain specification, a naming convention for identifiers in JavaScript languages:
Case sensitive, myname and myname are two different identifiers.
The first character of an identifier can be an underscore (_), a dollar character ($), or a letter beginning, not a number.
Other characters in an identifier can be an underscore (_), Dollar ($), letter, or number.
For example, identifier,username,user_name,_sys_val, height, $change are valid identifiers, and 2mail,room#,class is an illegal identifier. Among them, the use of Chinese "height" named variables are legal.
Note that the letters in JavaScript are unicode,unicode called the Unified Coding System, is the international general 16-bit coding system, it contains Asian text encoding, such as Chinese, Japanese, Korean and other characters. All the characters in JavaScript can be Asian letters in Chinese, Japanese, and Korean.