const has = (object, key) => (key in object);
const gendiff = (file1, file2) => {
const mergeFiles = { ...file1, ...file2 };
const uniqueKeys = Object.keys(mergeFiles);
const diff = uniqueKeys.map(key => {
if (has(file1, key) && has(file2, key) && typeof file1[key] === 'object' && typeof file2[key] === 'object') {
return { key, value: gendiff(file1[key], file2[key]), status: 'have a child' };
} else if (has(file1, key) && has(file2, key) && file1[key] !== file2[key]) {
return { key, value: { oldValue: file1[key], newValue: file2[key] }, status: 'changed' };
} else if (has(file1, key) && !has(file2, key)) {
return { key, value: file1[key], status: 'removed' };
} else if (!has(file1, key) && has(file2, key)) {
return { key, value: file2[key], status: 'new' };
} else if (has(file1, key) && has(file2, key) && file1[key] === file2[key]) {
return { key, value: file1[key], status: 'same' };
}
});
return diff;
};
console.log(gendiff(
{ workshop: { data: '2.0000000', locales: 'zh-CN.pak' } },
{ workshop: { config: 'd7', locales: 'am.pak' } }
));
/*
[
{
key: "workshop",
status: "have a child",
value: [
{ key: "data", value: "2.0000000", status: "removed" },
{
key: "locales",
status: "changed",
value: { oldValue: "zh-CN.pak", newValue: "am.pak" },
},
{ key: "config", value: "d7", status: "new" },
],
},
]
*/
$("input[data-type='currency']").on('keyup', ...)
меняете на $('#parts_tbody').on('keyup', 'input[data-type="currency"]', ...)
const activateBurger = () => {
document.querySelector('.header_feedback').style.zIndex = '82';
['.cross', '.cart_popup', '.popup', '.cart_overlay', 'progress'].forEach(
(sel) => document.querySelector(sel).classList.add('active');
};
document.querySelector('.burger_block').addEventListener('click', activateBurger);
const parentPos = document.getElementById('parent-id').getBoundingClientRect(),
const childPos = document.getElementById('child-id').getBoundingClientRect(),
const relativePos = const {
top: childPos.top - parentPos.top,
right: childPos.right - parentPos.right,
bottom: childPos.bottom - parentPos.bottom,
left: childPos.left - parentPos.left,
};
books[0] = 'text';
вы записали в нулевой элемент массива текстовое значение 'text'.books[0][1] = 'text';
в результате эквивалентна 'text'[1] = 'text';
, а при обращении к строке, как к массивоподобному объекту, изменить эту строку нельзя.console.log(books[0][1]);
должна выводить 'e', второй символ строки.const books = [ [], [] ];
books[0] = 'text';
books[0][1] = 'text';
console.log(books[0][1]); // e