const obj1 = {152: true, 153: true, 154: true};
const obj2 = {152: true, 153: true, 154: true, 2553: true, 2554: true, 2555: true};
const obj1keys= [...Object.keys(obj1)];
const obj2keys = [...Object.keys(obj2)];
const obj2keyFilter = obj2keys.filter(key=>obj1keys.includes(key));
obj2keyFilter.forEach(key => delete obj2[key]);
console.log(obj2);
const frontMenu = (...arrayOfLabel) => Telegraf.Extra.markdown().markup((m) => m.inlineKeyboard(
arrayOfLabel.map((a) => a.map((b) => m.callbackButton(b.name, b.callback))),
));
const [page, setPage] = useState(1);
const itemsPerPage = 8;
...
{orgs.slice((page - 1) * itemsPerPage, page * itemsPerPage).map(...)}
...
<button onClick={() => setPage(page + 1)}>Next</button>
<button onClick={() => setPage(page - 1)}>Previous</button>
Array.from({ length: 48 }, (n, i) => {
const d = new Date(0, 0, 0, 0, 30 * i);
return d.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
})
const countr = str => {
const result = {};
const len = str.length;
for (let i = 0; i < len; i++) {
const char = str[i];
if (!result[char]) result[char] = 0;
result[char]++;
}
return result;
}
const result = [...str].reduce((acc, n) => (acc[n] = (acc[n] ?? 0) + 1, acc), {});
function count(data, key = n => n) {
const counted = {};
for (const n of data) {
const k = key(n);
counted[k] = -~counted[k];
}
return counted;
}
const result = count(str);
const nums = [ -Infinity, -1, 0, 0, 0, 0, 69, 187, 666 ];
console.log(count(nums, Math.sign)); // {0: 4, 1: 3, -1: 2}
<div data-country="USA">New York</div>
<div data-country="USA">Boston</div>
<div data-country="USA">Las Vegas</div>
<div data-country="Japan">Osaka</div>
<div data-country="Japan">Tokyo</div>
<div data-country="Japan">Kyoto</div>
<div data-country="Japan">Yokohama</div>
<div data-country="Germany">Munich</div>
<div data-country="Germany">Dresden</div>
const cities = document.querySelectorAll('[data-country]');
console.log(count(cities, n => n.dataset.country)); // {USA: 3, Japan: 4, Germany: 2}
count(Array(9).keys(), n => [ 'чётные', 'нечётные' ][n & 1]) // {чётные: 5, нечётные: 4}
const { title, description, price, category, sizes, color, id } = singleItem;
const [chosenParameters, setParameters] = useState({ ...singleItem, size: '', color: ''});
const pickSize = (size) => {
setParameters({...chosenParameters, size: size});
};
const pickColor = (color) => {
setParameters({...chosenParameters, color: color});
};
component
- это тело страницы.