так почему же мы можем обр. к свойствам как у массива и тд...?
const r = Array.prototype.map.call('qwerty', (ch) => ch.toUpperCase());
console.log(r);
const arr1 = [{
VendorCode: 'kek',
Color: 'Черный',
Size: '35'
},
{
VendorCode: 'kek',
Color: 'Черный',
Size: '36'
},
{
VendorCode: 'kek',
Color: 'Белый',
Size: '35'
}
]
const arr2 = [{
Name: 'Белый',
Hex: '#FFF'
},
{
Name: 'Черный',
Hex: '#000'
}
]
// ------------------------------
const result = arr2.reduce((acc, value2) => {
if (arr1.find((value1) => value1.Name === value2.Color)) {
acc.push(value2.Hex);
}
return acc;
}, []);
// or
const result2 = arr2.reduce((acc, value2) => (arr1.find((value1) => value1.Name === value2.Color) && acc.push(value2.Hex), acc), []);
{
const transactions = [
{
date: '25.01.2015',
price: '28',
},
{
date: '22.02.2015',
price: '23',
},
{
date: '24.02.2015',
price: '12',
},
{
date: '02.03.2015',
price: '55',
},
{
date: '10.03.2015',
price: '56',
},
{
date: '15.03.2015',
price: '8',
},
{
date: '24.03.2015',
price: '19',
},
{
date: '26.03.2015',
price: '12',
},
{
date: '27.03.2015',
price: '11',
},
];
const firstMonthDate = 25;
const firstTransaction = transactions[0].date.split('.').map((n) => +n);
const increaseMonth = (date) => {
date.month = ((date.month + 12) % 12) + 1;
if (date.month === 1) {
date.year++;
}
};
const startDate =
firstTransaction[0] < firstMonthDate
? {
day: firstMonthDate,
month: ((firstTransaction[1] + 10) % 12) + 1,
year: firstTransaction[2] - (firstTransaction[1] === 1 ? 1 : 0),
}
: {
day: firstMonthDate,
month: firstTransaction[1],
year: firstTransaction[2],
};
const endDate = { ...startDate };
increaseMonth(endDate);
endDate.day--;
const sumByMonths = [
{
from: { ...startDate },
to: { ...endDate },
sum: 0,
},
];
let sumByMonthIndex = 0;
transactions.forEach((transaction) => {
const [day, month] = transaction.date.split('.').map((n) => +n);
if (
!(month === startDate.month && day >= startDate.day) &&
!(month === endDate.month && day <= endDate.day)
) {
increaseMonth(startDate);
increaseMonth(endDate);
sumByMonths.push({
from: { ...startDate },
to: { ...endDate },
sum: 0,
});
sumByMonthIndex++;
}
sumByMonths[sumByMonthIndex].sum += +transaction.price;
});
console.log('>>> sumByMonths', sumByMonths);
}
{
const transactions = [
{
date: '25.01.2015',
price: '28',
},
{
date: '22.02.2015',
price: '23',
},
{
date: '24.02.2015',
price: '12',
},
{
date: '02.03.2015',
price: '55',
},
{
date: '10.03.2015',
price: '56',
},
{
date: '15.03.2015',
price: '8',
},
{
date: '24.03.2015',
price: '19',
},
{
date: '26.03.2015',
price: '12',
},
{
date: '27.03.2015',
price: '11',
},
];
const firstMonthDate = 25;
const firstTransaction = transactions[0].date.split('.').map((n) => +n);
const increaseMonth = (date) => {
date.month = ((date.month + 12) % 12) + 1;
if (date.month === 1) {
date.year++;
}
};
const dateToString = (date) => `${date.year}-${date.month}-${date.day}`;
const startDate =
firstTransaction[0] < firstMonthDate
? {
day: firstMonthDate,
month: ((firstTransaction[1] + 10) % 12) + 1,
year: firstTransaction[2] - (firstTransaction[1] === 1 ? 1 : 0),
unix: 0,
}
: {
day: firstMonthDate,
month: firstTransaction[1],
year: firstTransaction[2],
unix: 0,
};
startDate.unix = +new Date(dateToString(startDate));
const endDate = { ...startDate };
increaseMonth(endDate);
endDate.unix = +new Date(dateToString(endDate)) - 1;
const sumByMonths = [
{
from: {
day: startDate.day,
month: startDate.month,
year: startDate.year,
},
to: { day: endDate.day - 1, month: endDate.month, year: endDate.year },
sum: 0,
},
];
let sumByMonthIndex = 0;
transactions.forEach((transaction) => {
const date = +new Date(transaction.date.split('.').reverse().join('-'));
if (!(date >= startDate.unix && date <= endDate.unix)) {
increaseMonth(startDate);
startDate.unix = +new Date(dateToString(startDate));
increaseMonth(endDate);
endDate.unix = +new Date(dateToString(endDate)) - 1;
sumByMonths.push({
from: {
day: startDate.day,
month: startDate.month,
year: startDate.year,
},
to: { day: endDate.day - 1, month: endDate.month, year: endDate.year },
sum: 0,
});
sumByMonthIndex++;
}
sumByMonths[sumByMonthIndex].sum += +transaction.price;
});
console.log('>>> sumByMonths', sumByMonths);
}
finally
{
if(con)
{
return con.end();
}
}
const props = ['prop1', 'prop2', ... , 'prop5'];
let i = 0;
const n = props.length;
console.log(
`твой хтмл в виде текста`.replace(/td itemprop=""/g, () => {
const newProp = `td itemprop="${props[i]}"`;
i = (i + 1) % n;
return newProp;
})
);
Если заменить монитор, то что будет предпочтительнее
1920x1080 на 25 дюймах или 2560x1440 на 27 дюймах
В некоторых моделях встречал функцию поворота в портретный режим, так ли это удобно
Есть ли разница между 60гц и 75гц в отношении влияния на усталость глаз?
Потянет ли такая конфигурация разрешение 2560x1440? (не в играх)
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
function a() {} /* = */ var a = function() {}