What does it mean?
1.
a==b&&b={}
2.
a==b||b={}
I didn't find answer
It means, if a equals b, then set b to an empty object. The second one means more or less the same. The difference is that the first one will not set b to an empty object if a and b are not equal. But the second one will always do that no matter what. That is because the OR operator in javascript continues where as the AND operator will short-circuit.
http://www.openjs.com/articles/syntax/short_circuit_operators.php
a==b
is the condition to be tested. The operators &&
and ||
test the condition very much like a ternary operator but you use it when there's only one condition you need to test, either false ||
or true &&
. It would be the same as:
if ( a == b ) { b = {} } // a == b && ( b = {} )
if ( a != b ) { b = {} } // a == b || ( b = {} )
But as Esailija pointed out in the comments, seems like you're missing some parenthesis:
a == b || ( b = {} )