DEV Community

Discussion on: Comparing Arrays using isArrayEquals() method

Collapse
 
harrison_codes profile image
Harrison Reid

This looks like a clean implementation for most use cases! One limitation is that I don't think it will handle equality comparisons where the array elements are themselves arrays or objects. For example:

console.log(isArrayEquals([{}, {}], [{}, {}]) // false
console.log(isArrayEquals([[], []], [[], []]) // false

Collapse
 
ra9 profile image
Carlos Nah • Edited

Thanks @Harrison Reid, at first my thoughts weren't focus on this aspect and now I will have to look into it and see what needs to be done.
And if you have a solution to share I will be grateful.

Collapse
 
harrison_codes profile image
Harrison Reid

I don't have any solution to share for the moment unfortunately, I don't think it's an easy problem to solve - particularly when considering deeply nested combinations of arrays and objects.

Thread Thread
 
ra9 profile image
Carlos Nah

Yeah sure but I do believe it can be solve.
Anything is possible

Thread Thread
 
harrison_codes profile image
Harrison Reid

Absolutely! Good luck with it 👍