On Tue, Aug 30, 2011 at 2:37 PM, Ivan S <[email protected]> wrote:

> var v1 = '1', v2 = '1', res = +v1 + +v2; alert(res);
>
>
> Why is this: res = +v1 + +v2 valid?
>
>
> From ECMAScript spec.:
>
> "The source text is scanned from left to right, repeatedly taking the
> longest possible sequence of characters as the next input element"
>
> Following that rule, wouldn't we get this tokens:
>
> (res) (=) (+v1) (++v2)
>
> because "++v2" is the longest possible token ("+" is shorter).
>
>
> Where am I wrong? :)
>

Whitespace. It's the difference between two distinct tokens and a single
single preincrement token.

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to