|| and && return value in js [error-prone]

|| and && will first perform a conditional judgment on the first operand, if it is not a Boolean value, it will first be converted to a Boolean type, and then the conditional judgment will be performed.

For ||, if the first condition evaluates to true, it returns the value of the first operand, and if it is false, it returns the value of the second operand.

&& is the opposite. If the condition is true, it returns the value of the second operand, and if it is false, it returns the value of the first operand.

|| and && return the value of one of their operands, not the result of conditional judgment [error-prone]

 

Guess you like

Origin blog.csdn.net/qq_42533666/article/details/129211820