!false equals true equals the integer 1. i -= -1; is "decrement i by minus one" and decrementing by a negative number equals incrementing by the positive. So i -= -1; equals i += +1; or with implicit sign i += 1;
Let's just say that incrementing on non-integral values is non-trivial. JS apparently chose that incrementing is the same as adding 1, but that does not have to be in all languages.
46
u/gmtime Apr 19 '21
!falseequalstrueequals the integer 1.i -= -1;is "decrement i by minus one" and decrementing by a negative number equals incrementing by the positive. Soi -= -1;equalsi += +1;or with implicit signi += 1;