Subj : JavaScript vs. C/C++ behavior
To : Digital Man
From : echicken
Date : Wed May 01 2019 05:46 pm
Re: JavaScript vs. C/C++ behavior
By: Digital Man to All on Wed May 01 2019 14:08:54
DM> In C/C++:
DM> i = 0 || 2; // i == 1
DM> In JavaScript:
DM> i = 0 || 2; // i == 2
DM> What about Java, C# or other C-like languages?
IIRC in Java this won't work at all, as it wants both operands to be boolean.
This caused me some mild annoyance a while back. I think it's the same in C#.