Sobes.tech
Middle

What will be the result of comparing an empty array with an empty string with loose comparison ([] == '')?

sobes.tech AI

Answer from AI

In JavaScript, loose equality comparison (==) involves type conversion. In the expression [] == '':

  • An empty array [] is converted to a primitive, becoming an empty string '' (via [].toString()).
  • The comparison is then '' == '', which is true.

Therefore, the result of the expression [] == '' will be true.

Example:

console.log([] == ''); // true
What will be the result of comparing an empty array… - sobes.tech