سلام
یه ارایه از ابجکتها دارم که const اما داره تغییر میکنه!!!!!!
در console.log پنجم ارایه array3 با console.log هشتم متفاوت هست در صورتیکه هیچ مقدار داخلش وارد نشده
const run = () => {
const array1 = {
"250-250#adv-14": [4, 5],
"250-250#adv-18": [6, 5],
"468-60#adv-19": [6, 4],
"300-250#adv-20": [4, 5],
};
const array2 = [
{ ID: "1", size: "250-250", positionTagID: "adv-14" },
{ ID: "2", size: "250-250", positionTagID: "adv-18" },
{ ID: "3", size: "468-60", positionTagID: "adv-19" },
{ ID: "3", size: "300-250", positionTagID: "adv-20" },
];
const array3 = {
"250-250": [
{
advID: 4,
second_delay: 42850,
},
{
advID: 5,
second_delay: 26700,
},
{
advID: 6,
second_delay: 31300,
},
{
advID: 7,
second_delay: 7000,
},
],
"300-250": [
{
advID: 4,
second_delay: 42850,
},
{
advID: 5,
second_delay: 26700,
},
{
advID: 6,
second_delay: 31300,
},
{
advID: 7,
second_delay: 7000,
},
],
"468-60": [
{
advID: 4,
second_delay: 41000,
},
{
advID: 5,
second_delay: 36100,
},
{
advID: 6,
second_delay: 22200,
},
{
advID: 7,
second_delay: 7000,
},
],
"970-90": [
{
advID: 4,
second_delay: 40600,
},
{
advID: 5,
second_delay: 34000,
},
{
advID: 6,
second_delay: 12700,
},
{
advID: 7,
second_delay: 7000,
},
],
};
console.log("=========== array1 ==========");
console.log(array1);
console.log("=====================");
console.log("=========== array3-1 ==========");
console.log(array3);
console.log("=====================");
for (let key in array2) {
const sizePosition = array2[key].size;
let sizeAndTagIDPosition =
array2[key].size + "#" + array2[key].positionTagID;
const array4 = array3[sizePosition];
removeItem(
array1[sizeAndTagIDPosition],
array4
);
}
console.log("=========== array3-2 ==========");
console.log(array3);
console.log("=====================");
};
const removeItem = (
item,
array4
) => {
for (let keyItem in item) {
for (let key in array4) {
if (
array4[key].advID ==
item[keyItem]
) {
array4.splice(key, 1);
break;
}
}
}
return array4;
};
run();