Write a JavaScript program to compare two objects to determine if the first one contains equivalent property values to the second one
- برمجة جافاسكربت java script
- برمجة
- 2021-06-03
- ahmadghneem
الأجوبة
//#Source https://bit.ly/2neWfJ2
const matches = (obj, source) =>
Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]);
console.log(matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true })); // true
console.log(matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true })); // false
console.log(matches({ hair: 'long', beard: true }, { age: 26, hair: 'long', beard: true })); // false
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال