Question

Can someone explain the following sentence(appeared in ECMAScript 5.1 Grammar Notation) in plain text?

ArgumentList :
AssignmentExpression
ArgumentList , AssignmentExpression

"states that an ArgumentList may represent either a single AssignmentExpression or an ArgumentList, followed by a comma, followed by an AssignmentExpression. This definition of ArgumentList is recursive, that is, it is defined in terms of itself. The result is that an ArgumentList may contain any positive number of arguments, separated by commas, where each argument expression is an AssignmentExpression. Such recursive definitions of nonterminals are common."

Was it helpful?

Solution

It means you can assign within the while (for example) clause and combine a number of assignments.

var a, b, c;
while (a, b = doSomething(), c = next())
{
 // Do stuff.
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top