How to determine whether there are different elements in two array objects of js

for example, there are two arrays

arr1 = [
    {"name": "" , "value" : "2", "type" : "1"},
    {"name": "" , "value" : "3", "type" : "1"},
    {"name": "" , "value" : "3", "type" : "1"},
    {"name": "" , "value" : "2", "type" : "1"},
    {"name": "" , "value" : "4", "type" : "1"}
  ]

arr2 = [
    {"name": "" , "value" : "2", "type" : "1" , num: "22", default: true},
    {"name": "" , "value" : "3", "type" : "1", num: "22", default: true},
    {"name": "" , "value" : "6", "type" : "2", num: "22", default: true},
    {"name": "" , "value" : "5", "type" : "1", num: "22", default: true},
    {"name": "" , "value" : "3", "type" : "1", num: "22", default: true},
    {"name": "" , "value" : "2", "type" : "1", num: "22", default: true},
    {"name": "" , "value" : "4", "type" : "1", num: "22", default: true}
  ]

to determine whether the name and value of all elements in arr1 exactly match the name and value of the element of arr2. If the name and value in an object in arr1 do not exist in arr2, return false. How to solve

May.05,2022

const map = {};
arr1.forEach(i => {
    map[`${i.name}_${i.value}`] = true;
});

const isSame = arr2.every(x => map[${x.name}_${x.value}]);

console.log('', isSame);

try

Menu