Deep comparison of objects
Description:
Comparing objects is not an easy task in JavaScript. The comparison operator only returns true if both variables point to the same object, that's why two objects with the same properties and values are different for JavaScript, like this:
var a = { name: 'Joe' };
var b = { name: 'Joe' };
a == b; //-> false
Sometimes it's really useful to detect when two objects have the same values.
Your task is to develop the deepCompare function to test if two objects have the same properties and values. Remember that an object can contain other objects. The function should also be able to correctly compare simple values, like strings and numbers (without using type coercion, please).
To make things simpler, it will only have to deal with simple values and objects and arrays containing strings, booleans and numbers, without taking into account regular expressions, dates and functions.
Similar Kata:
Stats:
Created | Jul 13, 2014 |
Published | Jul 13, 2014 |
Warriors Trained | 2971 |
Total Skips | 571 |
Total Code Submissions | 25242 |
Total Times Completed | 1026 |
JavaScript Completions | 1026 |
Total Stars | 92 |
% of votes with a positive feedback rating | 85% of 147 |
Total "Very Satisfied" Votes | 110 |
Total "Somewhat Satisfied" Votes | 29 |
Total "Not Satisfied" Votes | 8 |