js-keywords and reserved words

Source: Internet
Author: User

ECMA-262 describes a set of keywords that have a specific purpose. These keywords can be used to represent the start or end of a control statement, or to perform a specific operation. By rule, keywords are also language-reserved and cannot be used as identifiers. Here are all the keywords for ECMAScript (the 5th version of the New keyword with *):

Break Do instanceof typeof
Case Else New Var
Catch Finally Return void
Continue For Switch While
debugger* function This With
Default If Throw Delete
Inch Try


ECMA-262 also describes another set of reserved words that cannot be used as identifiers. Although reserved words do not have any specific purpose in this language. But they are likely to be used as keywords in the future. The following are all reserved words as defined in ECMA-262 version 3rd:

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


The 5th edition reduces the reserved words when running in non-strict mode to the following:

Class Enum Extends Super
Const Export Import


In strict mode, version 5th also imposes restrictions on the following reserved words:

Implements Package Public Interface
Private Static Let Protected
Yield


Note that let and yield are the new reserved words for the 5th edition, and the other reserved words are defined in version 3rd. To maximize compatibility, it is recommended that the reserved word defined in version 3rd be used as a reference when programming with let and yield.

Using keywords as identifiers in the JavaScript engine that implements ECMAScript 3 can cause "Identifier expected" errors. Using reserved words as identifiers may or may not cause the same error, depending on the particular engine.

The 5th edition made a few changes to the rules for using keywords and reserved words. Keywords and reserved words, although still not available as identifiers, can now be used as property names for objects. In general, it is best not to use keywords and reserved words as identifiers and property names for compatibility with future versions of ECMAScript.

In addition to the reserved words and keywords listed above, ECMA-262 version 5th also imposes restrictions on eval and arguments. In strict mode, these two names cannot be used as identifiers or property names, or an error is thrown.

js-keywords and reserved words

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.