0 && {}; / / 0
Copy the code

Explanation:

  • && and | | for short-circuit operator;
  • && means that the last value converted to true is returned if both are true, and the first value converted to false is returned if any value is converted to false.
  • | | said if is false, it returns the last value to false, if there are converted to the true value, then return the first converted to the true value.
1 && 2 && 3 // Return the last value converted to true => 3
1 && 0 && 3 Return the first value converted to false => 0
1 || 2 || 3 // Convert booleans to true, return the first value converted to true => 1
0 || null  // Convert booleans to false, return the last value converted to false => nullNote: All returns are original values, not Booleans.Copy the code

Summary sentence: “&” to find the value of the first Boolean false “| |” to find the first Boolean value to true.