4
By accident when I was changing a Javascript code I made, I put a comma instead of the ||
in an expression if
.
I altered if (that.busy || that.completed) return;
for if (that.busy, that.completed) return;
unintentionally, and I noticed that it did not generate any syntax error.
In addition, I did other tests that also did not generate errors:
var a = 1,
b = 2;
if (a, b) {
console.log('a', 'b');
}
if (1, b) {
console.log(1, 'b');
}
if (1, 2, 3) {
console.log(1, 2, 3);
}
Therefore, I did not understand why Javascript accept this. But probably this should have the purpose.
I wonder what that’s for.
I think this last sentence needs to be better elaborated. I didn’t want to edit to be invasive.
– Wallace Maxters
@Wallacemaxters can edit my English not very good.
– Hozeis