Deep Equal

Author
Engineering Manager, Robinhood
Languages

Implement a function deepEqual that performs a deep comparison between two values. It returns true if two input values are deemed equal, and returns false if not.

  • You can assume there are only JSON-serializable values (numbers, strings, boolean, null, objects, arrays).
  • There wouldn't be cyclic objects, i.e. objects with circular references.

Examples

deepEqual('foo', 'foo'); // true
deepEqual({ id: 1 }, { id: 1 }); // true
deepEqual([1, 2, 3], [1, 2, 3]); // true
deepEqual([{ id: '1' }], [{ id: '2' }]); // false

Asked at these companies

Premium FeaturePurchase premium to see companies which ask this question.
View plans
The fastest way to learn Front End – by building actual projects

Want to grow in your front end skills? Learn them the right way — build apps step-by-step while referencing best practices from Senior engineers.

Get 30% off now with BETA30 →

The fastest way to learn Front End – by building actual projects

Want to grow in your front end skills? Learn them the right way — build apps step-by-step while referencing best practices from Senior engineers.

Get 30% off now with BETA30 →