Implement a function deepEqual that performs a deep comparison between two values. It returns true if the two input values are deemed equal and false otherwise.
Inputs are limited to undefined, numbers, strings, booleans, null, arrays, and plain objects.
Arrays may be sparse. Their length and present indices are part of the structure being compared.
There will not 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
Hints
New
Asked at these companies
Unlock company signalsPremium shows which companies ask this question so you can prioritize practice by target company.