What does the following code output? const a = [1, 2, 3]; const b = [1, 2, 3]; console.log(a == b, a === b);

JavaScript Developer Medium

JavaScript Developer — Medium

What does the following code output? const a = [1, 2, 3]; const b = [1, 2, 3]; console.log(a == b, a === b);

Key points

  • JavaScript arrays are compared by reference
  • The variables a and b are pointing to different memory locations
  • The values inside the arrays are not compared in this case

Ready to go further?

Related questions