🗝️keyword
🚧 施工中
JS ⟩ grammar ⟩ token ⟩ keyword
A keyword is a token that matches IdentifierName (looks like an identifier), but also has a syntactic use. (📘ECMA )
// 54 keywords
as async await break case catch class const continue
debugger default delete do else enum export extends
false finally for from function get
if implements import in instanceof interface
let meta new null of package private protected public return
set static super switch target this throw true try typeof
var void while with yield
keywords can be divided into:
reserved word: never allowed as identifier (except
await
,yield
)contextually allowed as identifier: namely
await
,yield
.await
- reserved only inside async functions and modules.
contextually disallowed as identifier, in strict mode code:: let,
static
,implements
,interface
,package
,private
,protected
,public
.mostly allowed as identifier, but also appear as keywords within certain syntactic productions, at places where identifier is not allowed:
as
,async
,from
,get
,meta
,of
,set
,target
.
NaN
/Infinity
/ undefined is:
not keyword.
immutable & read-only properties of the global object.
JS doesn't throw any errors if you declare them in the global scope.
avoid using reserved word as identifiers (at least for variable/function) ❗
in dot notation (.), it's OK to use reserved word as property name❗
Last updated
Was this helpful?