I am trying to compare the object by only KEYS.
var obj1 = [ {"depid": "100", "depname": ""}, {"city": "abc", "state": "xyz"}, {"firstName": "John", "lastName": "Doe", "contactno": {"ph": 12345, "mob": 485428428}} ];
var obj2 = [ {"firstName": "John", "lastName": "Doe", "contactno": {"ph": 12345, "mob": 485428428}}, {"depid": "100", "depname": "role"}, {"city": "abc", "state": "xyz"} ];
For example, If we compare object in obj1 {"depid": "100", "depname": ""} with obj2 {"depid": "100", "depname": "role"}, must return true. Since the keys are same. I need to set the values of obj2 in obj1.
//Expected result
obj1 = [ {"depid": "100", "depname": "role"}, {"city": "abc", "state": "xyz"}, {"firstName": "John", "lastName": "Doe", "contactno": {"ph": 12345, "mob": 485428428}} ]
I have tried the solution provided in this link But still not able to compare only on object keys and update the values from obj2 to obj1