Why console.log([] == []) Is False in JavaScript (Interview Question Explained)

Ever wondered why [] == [] is false in JavaScript? Learn the real reason with simple explanations and interview-ready examples.

ALLJAVASCRIPT

Adarsh Bharadwaj S

12/15/20251 min read

Why [] == [] Confuses Almost Every JavaScript Developer

At first glance, this looks strange:

Most beginners expect this to return true.
After all, both sides look exactly the same — empty arrays.

But JavaScript says:

This single line question has confused millions of developers and is a favorite in JavaScript interviews.

Let’s break it down in the simplest way possible.

The Real Reason Behind the Result

In JavaScript, arrays are objects.

And when JavaScript compares objects, it does not compare their values — it compares their memory references.

That means:

  • [] creates a new object in memory

  • Another [] creates a different object in memory

Even though they look the same, they are stored in different locations.

So JavaScript sees this as:

Hence, the result is false.

Easy Way to Understand (Real-Life Example)

Think of two identical keys 🔑
They look the same, but they open different locks.

Same shape ≠ Same reference

That’s exactly how JavaScript treats arrays and objects.

What About This Case?

Why?
Because both a and b point to the same memory location.

Interview Question You Will Face

Q: Why does [] == [] return false in JavaScript?
Perfect Interview Answer:

Because arrays are objects in JavaScript, and object comparison is based on reference, not value. Each array has a different memory reference.

This answer instantly tells the interviewer:
✔ You understand JavaScript internals
✔ You’re not just memorizing syntax

Common Beginner Mistake

Many developers try to compare arrays like this:

This will almost always fail.

Correct Approach

Convert arrays to values:

Or compare elements manually.

Key Takeaways

✔ Arrays are objects
✔ Objects are compared by reference
✔ Same-looking arrays ≠ same object
✔ Interviewers love this concept

Final Thoughts

JavaScript looks simple, but small details like this separate average developers from strong ones. If you understand why [] == [] is false, you’re already ahead of many candidates.