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.
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.