Home >Web Front-end >Front-end Q&A >Is int a JavaScript reserved word?
int is a reserved word in JavaScript. JavaScript contains multiple reserved words: abstract, enum, int, short, boolean, export, interface, static, byte, extends, long, super, etc.
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
Reserved words are a set of names (or commands) prepared for use within the JavaScript language specified by ECMA-262. These names currently have no specific purpose and are reserved for JavaScript upgrade versions. Users are advised not to use them. Specific instructions are shown in the table.
abstract | double | goto | native | static |
boolean | enum | implements | package | super |
byte | export | import | private | synchronized |
char | extends | int | protected | throws |
class | final | interface | public | transient |
const | float | long | short | volatile |
ECMAScript 3 lists all Java keywords as reserved words, while ECMAScript 5 has more flexible regulations.
For example, in non-strict mode, only class, const, enums, export, extends, import, and super are reserved words, and other ECMAScript 3 reserved words can be used freely; in strict mode, ECMAScript 5 becomes Be more cautious and strictly limit the use of implements, interface, let, package, private, protected, public, static, yield, eval (non-reserved words), and arguments (non-reserved words).
Note:
Using keywords as identifiers in code will cause an "Identifier Expected" (missing identifier) error in most browsers. Using reserved words may not cause the same error, depending on the browser. In general, it is best not to use keywords and reserved words as identifiers to maintain compatibility with future versions of ECMAScript.
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of Is int a JavaScript reserved word?. For more information, please follow other related articles on the PHP Chinese website!