4 ms·
You also need to know how tokens are produced by lexical analysis. It could have produced: 'num1' '+' '++' 'num2' In fact it produces 'num1' '++' '+' 'nu
by jonsen 14y ago
You also need to know how tokens are produced by lexical analysis. It could have produced:
'num1' '+' '++' 'num2'
In fact it produces
'num1' '++' '+' 'num2'
so it's not about evaluate from left-to-right.
- prophetjohn 14y agoIs there a case in JavaScript where operators with the same precedence are not evaluated left-to-right?
- jonsen 14y agoI don't know. But I happen to know that the javascript tokenizer matches the longest possible substring. Therefore it takes '++' from '+++..', not '+'. It's not about precedence. EDIT: Yes, the assignment operators, =, += etc., evaluates right to left.