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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:50:24+00:00 2026-05-28T05:50:24+00:00

According to MDN documentation for JSON.stringify : Properties of non-array objects are not guaranteed

  • 0

According to MDN documentation for JSON.stringify:

Properties of non-array objects are not guaranteed to be stringified
in any particular order. Do not rely on ordering of properties within
the same object within the stringification.

I had hoped to determine if an object changed by caching a stringified version of the object, then comparing it to a subsequently stringified version of the object. That seemed much simpler than recursively iterating through the object and doing comparisons. The problem is that because the JSON.stringify function is not deterministic, I could technically get a different string when I stringify the same object.

What other options do I have? Or do I have to write a nasty compare function to determine object equality?

  • 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-28T05:50:25+00:00Added an answer on May 28, 2026 at 5:50 am

    I am pretty sure this is because of the way different JavaScript engines keep track of object properties internally. Take this for example:

    var obj = {
    "1" : "test",
    "0" : "test 2"
    };
    
    for(var key in obj) {
        console.log(key);
    }
    

    This will log 1, 0 in e.g. Firefox, but 0, 1 in V8 (Chrome and NodeJS).
    So if you need to be deterministic, you will probably have to iterate through each key store it in an array, sort the array and then stringify each property separately by looping through that array.

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

Sidebar

Related Questions

According documentation: System.Array.Sort<T> - sorts the elements in an entire System.Array using the System.IComparable
I need help with this two elements properties. According MDN element.scrollHeight this a height
According to the documentation, they're pretty much interchangeable. Is there a stylistic reason to
According to select name from system_privilege_map System has been granted: SELECT ANY TABLE ...and
According to the feedparser documentation , I can turn an RSS feed into a
According to the PHP docs, one can initialize properties in classes with the following
According to the jQuery manual you can send extra parameters (as an array) when
There is HTML page with contents like this. Documentation at MDN says that childNodes
According to the MDN JS Doc , the charAt method takes in an integer
According to what I've heard, integer values that are not the processor's word size

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.