I would like to compare two objects and want to make one new object which have common proprty of it. I have seen lot of solutions to take difference but not sure how we can take common values.
Here is my objects where if obj1 have iscommisionAccount false and obj2 have iscommisonAccount true then my result should not have value as it is not matched if both have same property then only will get result.
I know we can use filter if we have arrays of objects but what if we have only objects.
obj 1 = {
"val1":"test",
"stream":{
"iscommisonAccount":false,
"istradeAccount":true
}
}
obj 2 = {
"val1":"test",
"stream":{
"iscommisonAccount":true,
"istradeAccount":true
}
}
result = {
"stream":{
"istradeAccount":true
}
}
diffrent examples:
obj 1 = {
"val1":"test",
"stream":{
"iscommisonAccount":false,
"istradeAccount":true
}
}
obj 2 = {
"val1":"test",
"stream":{
"iscommisonAccount":true,
"istradeAccount":false
}
}
result = {
"stream":{
}
}
or
obj 1 = {
"val1":"test",
"stream":{
"iscommisonAccount":true,
"istradeAccount":true
}
}
obj 2 = {
"val1":"test",
"stream":{
"iscommisonAccount":true,
"istradeAccount":true
}
}
result = {
"stream":{
"iscommisonAccount":true,
"istradeAccount":true
}
}