Comparing objects in JavaScript

See this ball? Its colour is red. Call it ball1.

See this ball? Its colour is red. Call it ball2.

Is ball1 the same object as ball2? No, they are distinct objects that happen to have identical properties.


See this ball? Its colour is red. Call it ball1.

Let’s call ball1, ball2.

Is ball1 the same object as ball2? Yes. They are the same ball.

Leave a Comment