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 7413511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:55:17+00:00 2026-05-29T06:55:17+00:00

I have two arrays. In each array I have objects with lots of properties

  • 0

I have two arrays. In each array I have objects with lots of properties but no methods.
I need to see if array 1 is equal with array 2.

One way to do that would be to create a function that pass through each element of an array and compare each property of the object with the object in the similar position in the second array.

The problem is that the arrays are quite big and also each object has lots of properties. I was wandering if there could be another way. In C++ for example I could read memory… but I don’t know how to do that in js.

I need to obtain the most optimal way since this is part of a function that is used often.

  • 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-05-29T06:55:18+00:00Added an answer on May 29, 2026 at 6:55 am

    Unless they are the same array instance, comparing the memory locations won’t work in JavaScript (what happens when you do arr1 == arr2).

    You would need to explicitly loop.

    Some people use JSON.stringify() (watch out for the gotcha explained in the comments by pimvdb) on both arrays and compare the resulting strings to cheat, but serialising to a string and comparing sounds over fully expensive to me. However it works, so if there is no performance problem, go nuts! 🙂

    You could also try toSource().

    I would build my own comparative function that compares just enough that satisfies my idea of identical.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays of objects. I would like iterate over each of these
I have two arrays. One is an array of names and the other is
I have two arrays of JavaScript Objects that I'd like to compare to see
I have two arrays with different attributes for the objects contained in each. participants
I have a two dimensional JSON array where each element contains several attributes. The
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two arrays. One contains id=>count and the other contains id=>name . I'm
I have two arrays containing the same elements, but in different orders, and I
I have two arrays in PHP. The first array ($author_array) is comprised of user_ids

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.