Strange cyclic tuple

I am writing a JavaScript parser and testing it in the prototype.js library, it made an error in this code:

line 4000:

while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) { soFar = m[3]; parts.push( m[1] ); if ( m[2] ) { extra = m[3]; break; } } 

I reduced this to:

 while ( (a, b) == c ) {} 

Is this really valid JavaScript? According to ECMA-262, the while loop has the following syntax:

 while ( Expression ) Statement 

What is the expression (a, b) == c ? I did not think that tuples are supported in JavaScript?

+4
source share
1 answer

This is not a tuple; that comma (also see Wikipedia ). The comma operator evaluates the first operand, and then the second operand and gives the value of the second.

+6
source

Source: https://habr.com/ru/post/1398524/


All Articles