What is the output of the following? “`js const a = [1, 2]; const b = [1, 2]; console.log(a == b, a === b); “`

JavaScript Developer Hard

JavaScript Developer — Hard

What is the output of the following? “`js const a = [1, 2]; const b = [1, 2]; console.log(a == b, a === b); “`

Key points

  • JavaScript compares arrays by reference, not by value
  • The arrays a and b are two separate instances
  • The comparison returns false for both == and ===

Ready to go further?

Related questions