Search code examples
javascriptundefined

undefined keyword in javascript


I'm reading the ECMA-262 and see the following:

PrimaryExpression :
    this 
    Identifier 
    Literal 
    ArrayLiteral 
    ObjectLiteral 
    ( Expression )
Literal ::
    NullLiteral 
    BooleanLiteral 
    NumericLiteral 
    StringLiteral 
    RegularExpressionLiteral

As we can see there is no undefined in the PrimaryExpression defenition. So, how does undefined is evaluating and to what type of expression it belongs?


Solution

  • undefined is not a keyword. It is a global read-only variable which represents the value undefined. This means it falls under the category of Identifier as listed under PrimaryExpression in your list.