Evertjan.
5/25/2015 12:18:00 PM
Steven D'Aprano <steve@pearwood.info> wrote on 25 mei 2015 in
comp.lang.javascript:
> Consider:
>
>js> var x = (1,2,3);
>js> x
> 3
Reconsider:
var x = (i=4,++i,i=i*10,a=7,"blah",++i);
alert(x); // 51
alert(i); // 51
alert(a); // 7
var x = (i=4,++i,i=i*10,a=7,"blah",i++);
alert(x); // 50
alert(i); // 51
alert(a); // 7
var x = (i=4,++i,i=i*10,a=7,"blah",++i,"done");
alert(x); // done
alert(i); // 51
alert(a); // 7
So it seems just a set of statements executed in line,
the result value of the last one returned.
Compare this to:
(i=4,++i,i=i*10,a=7,-3,x=i++);
alert(x); // 50
alert(i); // 51
alert(a); // 7
and to:
i=4;++i;i=i*10;a=7;-3;x=i++;
alert(x); // 50
alert(i); // 51
alert(a); // 7
However this errors:
(var i=4,++i,i=i*10,a=7,-3,i++);
Why?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)