Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8006937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:40:19+00:00 2026-06-04T17:40:19+00:00

For example, in Javascript [1,2,3] === [1,2,3] and [1,2,3] == [1,2,3] are both false.

  • 0

For example, in Javascript [1,2,3] === [1,2,3] and [1,2,3] == [1,2,3] are both false. Even the simpler case of the empty array is also false. The reason being that arrays are reference types and [1,2,3] and [1,2,3] are different as references. Javascript is not unique in this regard and pretty much every language implements equality as being reference equality except for the most basic types like integers and maybe some built-in types.

Why is this the case? What’s so hard about making the default equality operator something stronger? So instead of just comparing references why is it so hard to compare structural properties as well?

I know that many languages provide facilities for overloading certain operators to mean something else so that == will mean what you want it to mean instead of the usual weak reference equality. My question is not whether the language provides such facilities but why the default equality operator isn’t something more sensible so that [1,2,3] == [1,2,3] evaluates to true by default and requires no programmer intervention.

In python the above example evaluates to true but if you define the following class

class A:
  def __init__(self, prop):
    self.prop = prop

and then compare a = A(1) to b = A(1) then the answer will be false even though structurally a and b are the same and there is no way to tell them apart if all you know is the bit pattern that defines the object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:40:20+00:00Added an answer on June 4, 2026 at 5:40 pm

    Not all languages work the way you describe. For example, in Python == is equality and is is reference comparison:

    >>> a = [1,2,3]
    >>> b = [1,2,3]
    >>> a == b
    True
    >>> a is b
    False
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for some kind of example of a Javascript Time Picker that
Possible Duplicate: javascript compare strings without being case sensitive. I am having two fields.
For example in javascript var image = new Image(); image.onerror = function(e) { //
For example if JavaScript performs a bunch of manipulations on a table, the new
I found the following javascript example for uploading multiple files in one session: Upload
I want to set clock of multiple country by JavaScript: Example : U.S.A India
In the wikipedia entry Unobtrusive JavaScript there is an example of obtrusive JavaScript: <input
sometimes i use debug code to alert something in javascript (for example, matching something
I want to extract the text between the last () using javascript For example
I use Javascript. For example: sound = []; for (var i = 0; i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.