const array1= [{row: 101},{row: 102}];
const obj1 ={101: 'someValue', 102 : 'someValue1'}
here I want to return true if array1 of values example(in this case 101 and 102) matches with obj1 key's that are 101 and 102 else need to return false
CodePudding user response:
array1.every(({row}) => obj1.hasOwnProperty(row))
Be aware that if obj1 has another property, e.g. 103: 'someValue3'
, it will still be true.
And also it is recommended to call it using Object.prototype.hasOwnProperty.call(obj1, row)