-1

it shows error when i run it like this. but if i first use document.write(x=4,++x); //45 and then write again document.write(x=4 + ++x ) it surprisingly runs and shows me output //4510

can anyone tell me why

rrk
  • 15,677
  • 4
  • 29
  • 45

1 Answers1

4

After the first write, x is 5 and 45 is written, then you do x=4 + ++x which evaluates to x=4 + 6 which is 10, so it writes 10, leaving you with 4510.

Aplet123
  • 33,825
  • 1
  • 29
  • 55