3

How can I check if two JavaScript values are the same?

If they are objects, I would like to compare them key-by-key recursively.

I'm looking for an existing function, not a way to write my own like described in this question: Object comparison in JavaScript.

3 Answers 3

5

There's a function called deepDiffer which does this.

Sign up to request clarification or add additional context in comments.

1 Comment

Haha OK someone didn't like that answer ;)
2

Took a bit of Googling to find how to import deepDiffer.

import deepDiffer from 'react-native/lib/deepDiffer'

...

deepDiffer(obj1, obj2) // true or false

Comments

2

In react native >= 0.62.2 use,

import deepDiffer from `react-native/libraries/utilities/differ/deepDiffer`

deepDiffer(obj1, obj2) // true or false

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.