摘自:《JavaScript Visual QuickStart Guide (8th Edition)》。
Reversed words are words that have special meaning to JavaScript. Therefore, they cannot be used as variable or function names.
目录
ECMAScript Edition 3 Reserved Words
These words are part of the JavaScript language as of ES3.
- break
- case
- catch
- continue
- default
- delete
- do
- else
- finally
- for
- function
- if
- in
- instanceof
- new
- return
- switch
- this
- throw
- try
- typeof
- var
- void
- while
- with
ES3 Future Reserved Words
- abstract
- boolean
- byte
- char
- class
- const
- debugger
- double
- enum
- export
- extends
- final
- float
- goto
- implements
- import
- int
- interface
- long
- native
- package
- private
- protected
- public
- short
- static
- super
- synchronized
- throws
- transient
- volatile
ECMAScript Edition 5 Reserved Words
This is ES5’s list of reserved words. It’s similar to that of ES3, but given that browsers primarily suppot ES3, we recommend that you keep both lists in mind.
- break
- case
- catch
- continue
- debugger
- default
- delete
- do
- else
- finally
- for
- function
- if
- in
- instanceof
- new
- return
- switch
- this
- throw
- try
- typeof
- var
- void
- while
- with
ES5 Future Reserved Words
- class
- const
- enum
- export
- extends
- implements
- import
- interface
- let
- package
- private
- protected
- public
- static
- super
- yield
Oter identifiers to avoid
These (along with the object names) aren’t officially reserved, but as they are (or may be) part of the JavaScript language, you shouldn’t use them as function or variable names. If you do, abandon all hope; the results will be unpredictable.In addition, most browsers are case-sensitive, which means that they differentiate between
- abstract
- arguments
- Array
- Boolean
- byte
- call
- cast
- char
- Date
- decimal
- decodeURI
- decodeURIComponent
- double
- dynamic
- each
- encodeURI
- encodeURICompnent
- Error
- eval
- EvalError
- false
- final
- float
- Function
- generator
- get
- goto
- has
- include
- Infinity
- int
- internal
- intrinsic
- is
- isFinite
- isNaN
- JSON
- like
- long
- Math
- namespace
- NaN
- native
- null
- Number
- Object
- override
- parseFloat
- parseInt
- precision
- prototype
- RangeError
- ReferenceError
- RegExp
- rounding
- set
- short
- standard
- strict
- String
- synchronized
- SyntaxError
- throws
- to
- transient
- true
- type
- TypeError
- uint
- undefined
- URIError
- use
- volatile
- xml