Deep equal with sorted keys in an object.
See original GitHub issueIs there a way to perform a deep equal to check if the keys are in a defined order? example:
let a = {
a: 1,
b: {
a: {
a: 1,
b: 1
}
}
};
let b = {
b: {
a: {
b: 1
a: 1,
}
},
a: 1
};
Here a is equal to b as they have the same properties. But since they are not in the given order, i would like for the test to fail.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Sort JavaScript object by key - Stack Overflow
Here's how you can sort an object by its keys/properties, alphabetically: ... according to the following rule: if two items compare as equal,...
Read more >How to Compare 2 Objects in JavaScript | SamanthaMing.com
One quick way to compare if 2 objects have the same key value, is using JSON.stringify . ... Yup, the 2 ways also...
Read more >How to Sort JavaScript Object by Key - W3docs
In this tutorial, we will share a very simple and functional method to sort an array of objects by key. Here is a...
Read more >Arrays (Java Platform SE 7 ) - Oracle Help Center
This class contains various methods for manipulating arrays (such as sorting and searching). This class also contains a static factory that allows arrays...
Read more >Array vs Set vs Map vs Object — Real-time use cases in ...
There is no built-in method for the sorting of the objects, but ES6 offers some interesting built-in key-sorting during the creation of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think
deep.ordered.keys
sounds like a fantastic assertion to add!@ancmikesmullin unfortunately this is no longer true. The ES6 and above specs specify that keys are ordered by creation order.