โš–๏ธidentifier vs. keyword

JS โŸฉ identifier โŸฉ vs. keyword

there are 5 categories of identifier names:

  • not keywords (always allowed as identifiers)๏ผš Math, window, toString, _ ...

  • keywords๏ผš

    • never allowed as identifiers๏ผš reserved word (except await, yield)

    • contextually allowed as identifiers๏ผš namely await, yield.

    • contextually disallowed as identifiers, in strict mode code:๏ผš let, static, implements, interface, package, private, protected, public.

    • always allowed as identifiers, but also appear as keywords within certain syntactic productions, at places where identifier is not allowed: as, async, from, get, meta, of, set, target.

The term conditional keyword, or contextual keyword, is sometimes used to refer to the keywords that fall in the last 3 categories, and thus can be used as identifiers in some contexts and as keywords in others. ๐Ÿ“˜ECMA

Last updated