js keywords and reserved words

Original link: https://www.mk2048.com/blog/blog.php?id=h02hkh2h1i0j&title=js+%E5%85%B3%E9%94%AE%E5%AD%97%E5%92%8C%E4 % BF% 9D% E7% 95 % 99% E5% AD% 97

You can not put keywords, reserved words, true, false and null as identifiers.

js keyword can be used in a control statement beginning or end, or the like for performing a specific operation. As a rule, the language keyword is reserved and can not be used as an identifier. The following is ECMAScription all keywords:

  break、else、new、var、 case、  finally 、 return、 void 、 catch  、for  、switch 、 while 、 continue、  function  、this 、 with 、default 、 if 、 throw 、 delete 、 in 、  try 、do 、 instranceof、  typeof

ECMA also describes another group of words can not be reserved as an identifier. Although the reserved words in the language are not yet any specific purpose, but they may in the future be used as keywords. Here is the definition of the third edition of ECMA all reserved words:

abstract 、 enum   、int 、 short 、 boolean  、export  、interface、  static、  byte  、extends 、 long 、 super 、 char 、 final  、native  、synchronized 、 class  、float 、 package  、throws 、 const  、goto  、private 、transient 、 debugger 、 implements  、protected 、 volatile 、 double  、import  、public

Use keywords as identifiers are actually "Identifier Expected" (lack identifiers) errors in most browsers in your code. The use of reserved words may not result in the same error, depending on specific browsers may be. In general, it is best not to use keywords and reserved words as identifiers, again maintaining compatibility with future versions of ECMAScript.

This article is taken "JavaScripti senior programmer design (2nd edition)" 

 


More professional front-end knowledge, make the [2048] ape www.mk2048.com

Guess you like

Origin blog.csdn.net/qq_29069777/article/details/102755037