-1

I want to compare two objects as below:

First object:

const permissions = {
  "statistics":{"list":"1"},"audit":{"list":"1"}}
}

Second object:

const userPermission = 
{
  "audit":{"list":"1"}
}

So, if the second object has some value the same as the first object then return true. In this sample I want it return true. Becuase, audit has same properties.

Chanty Sok
  • 27
  • 1
  • 6

1 Answers1

0
var obj1 = {
name:'hello',
age:12,
fav: 'fav',
foo: 'foo'
}

var obj2 = {
name: 'hey',
say: 'say',
prop: 'prop',
top: 'top'
}

var common = Object.keys(obj1).filter(obj1item =>  Object.keys(obj2).indexOf(obj1item) !== -1 );

console.log(common);

You can look into this > Is there a way to check and see if two objects have properties in common?