Is a JavaScript function call a LeftHandSideExpression, thus an ExpressionStatement?

后端 未结 1 1523
孤街浪徒
孤街浪徒 2021-01-23 01:12

I\'m trying to prove that a simple function call such as

window.alert();

is valid EcmaScript 2016 (7th Edition) grammar. Working backward, with

1条回答
  •  臣服心动
    2021-01-23 01:46

    An AssignmentExpression does not necessarily need to be an assignment, it only means "an assignment could stand here". It can also consist of solely a ConditionalExpression. And now we need to go down the whole chain of associativity rules:
    A ConditionalExpression can contain a ternary operator or consist solely of a LogicalORExpression. A LogicalORExpression can contain an || operator or consist solely of a LogicalANDExpression. And so on: A LogicalANDExpression can consist solely of a BitwiseORExpression which can consist of solely a BitwiseXORExpression which can consist of solely a BitwiseANDExpression which can consist of solely an EqualityExpression which can consist of solely a RelationalExpression which can consist of solely a ShiftExpression which can consist of solely an AdditiveExpression which can consist of solely a MultiplicativeExpression which can consist of solely an ExponentiationExpression which can consist of solely a UnaryExpression which can consist of solely an UpdateExpression.

    Which finally can consist of the LeftHandSideExpression that we were looking after.

    0 讨论(0)
提交回复
热议问题