JavaScript is easy. There are no rules so just do whatever you want and when it sometimes does something entirely unexpected just chalk it up as a fluke and carry on. Semicolons to end statements? Sometimes, sometimes not who cares. Types? Fuck it they're all var. Dates? Yeah sometimes it'll be UTC sometimes EST sometimes the time on Mars, that's the users problem.
I’ll assume weak typing/C-syntax and rules; also going to treat this an expression rather than any sort of statement.
My answer:
If x initially had a non-zero (i.e. true) value, then the expression evaluates to 2 or 2.5 depending on if x is an integral or floating point, respectively. Also x has been assigned that same value.
Otherwise, x == 0 and the expression simply evaluates to ;.
104
u/mrbmi513 Jan 05 '19
What is the value of x?
int x = 5/2.0;