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

  • Home
  • SEARCH
  • 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 7698289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:12:26+00:00 2026-05-31T22:12:26+00:00

What is the most efficient way to compare two JSON-formatted objects data in node.js?

  • 0

What is the most efficient way to compare two JSON-formatted objects data in node.js?

These objects do not contain “undefined” or functions and their propotype is Object.

I’ve heard there is a good support if JSON in node.js

  • 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-31T22:12:27+00:00Added an answer on May 31, 2026 at 10:12 pm

    Friends! I’m really sorry if I don’t understand something, or explain question in wrong terms. All I wanna do is to compare the equality of two pieces of JSON-standardized data like this:

    {"skip":0, "limit":7, "arr": [1682, 439, {"x":2, arr:[]}] }

    {"skip":0, "limit":7, "arr": [1682, 450, "a", ["something"] }

    I’m 100% sure there will be no functions, Date, null or undefined, etc. in these data. I want to say I don’t want to compare JavaScript objects in the most general case (with complex prototypes, circular links and all this stuff). The prototype of these data will be Object. I’m also sure lots of skillful programmers have answered this question before me.

    The main thing I’m missing is that I don’t know how to explain my question correctly. Please feel free to edit my post.

    My answer:

    First way: Unefficient but reliable. You can modify a generic method like this so it does not waste time looking for functions and undefined. Please note that generic method iterates the objects three times (there are three for .. in loops inside)

    Second way: Efficient but has one restriction. I’ve found JSON.stringify is extremely fast in node.js. The fastest solution that works is:

    JSON.stringify(data1) == JSON.stringify(data2)

    Very important note! As far as I know, neither JavaScript nor JSON don’t matter the order of the object fields. However, if you compare strings made of objects, this will matter much. In my program the object fields are always created in the same order, so the code above works. I didn’t search in the V8 documentation, but I think we can rely on the fields creation order. In other case, be aware of using this method.

    In my concrete case the second way is 10 times more efficient then the first way.

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

Sidebar

Related Questions

Both do the same thing. What is the most efficient way to compare two
Which way is the most efficient way to save sql data compare base-64 or
I'm looking for the most efficient way to compare two sets of two columns,
What's the most efficient way to compare two python values both of which are
TL DR; What is the most efficient way to sort and compare values in
What is the most efficient way to go through and update every single node
What is the most efficient/recommended way of comparing two NSDates? I would like to
Would anyone please be able to tell me the most efficient way to compare
I am trying to find the most efficient, optimized and fastest way to compare
What's the most efficient way to concatenate strings?

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.