массивСДанными.map((n, i) => {
const Component = i % через_сколько_там_надо_чередовать_компоненты
? КомпонентРаз
: КомпонентДва;
return <Component {...n} />;
})
.item:nth-child(2n) {
background-color: red;
}
<div v-for="n in items" class="item">
<div v-for="(n, i) in items" :style="i & 1 && { backgroundColor: 'red' }">
strval(intval($str))
preg_replace('~^0+~', '', $str)
Я новичок в python
if change_index <= len(alphabet): result_text += alphabet[change_index]
function Ranges(props) {
const onChange = ({ target: t }) => {
const index = +t.dataset.index;
const value = +t.value;
const values = props.values.map((n, i) => i === index ? value : n);
if (props.max >= values.reduce((acc, n) => acc + n, 0)) {
props.onChange(values);
}
};
return (
<div>
{props.values.map((n, i) => (
<div>
<input
type="range"
data-index={i}
max={props.max}
value={n}
onChange={onChange}
/>
{n}
</div>
))}
</div>
);
}
const groupedAndSortedArr = Object
.values(arr.reduce((acc, n) => ((acc[n[0]] ??= []).push(n), acc), {}))
.sort((a, b) => a[0][0].localeCompare(b[0][0]));
str.split('=').pop()
// или
str.slice(str.indexOf('=') + 1)
str.replace(/[^=]*=/, '')
// или
str.match(/(?<==).*/)[0]
// или
/[^=]*$/.exec(str).shift()
new URLSearchParams(str).get('sort')
const obj = [...str.matchAll(/([^?&]+)=([^&]+)/g)]
.reduce((acc, [ , k, v ]) => (
k.endsWith('[]')
? (acc[k.slice(0, -2)] ??= []).push(v)
: acc[k] = v,
acc
), {});
const params = new URLSearchParams(str);
const reg = /\[\]$/;
const obj = Object.fromEntries(Array.from(
new Set(params.keys()),
n => [
n.replace(reg, ''),
params[reg.test(n) ? 'getAll' : 'get'](n),
]
));
const obj = str.split('?').pop().split('&').reduce((acc, n) => {
let [ k, v ] = n.split('=');
const isArr = k.slice(-2) === '[]';
k = k.substring(0, k.length - isArr * 2);
const target = (isArr ? (acc[k] = acc[k] || []) : acc);
target[isArr ? target.length : k] = v;
return acc;
}, {});
Как правило, все плагины работают от обратного - у них есть возможность передать массив только с неактивными датами.
config.enable
.дата => массив.includes(дата.toLocaleDateString())
:disbaledDates.customPredictor
.beforeShowDay
. $grouped = [];
foreach ($arr as $n) {
$grouped[$n['category_id']][] = $n['text'];
}
foreach ($grouped as $key => $values) {
echo "
<fieldset>
<legend>$key</legend>".
implode('', array_map(fn($n) => "<div>$n</div>", $values))."
</fieldset>";
}
const key = 'strategy';
.const result = arr.filter(function(n) {
return this.has(n[key]);
}, new Set(arr2));
const result = arr2.flatMap(((values, n) => values[n] ?? []).bind(
null,
arr.reduce((acc, n) => ((acc[n[key]] ??= []).push(n), acc), {})
));
const result = [];
for (const n of arr) {
for (const m of arr2) {
if (m === n[key]) {
result.push(n);
break;
}
}
}
const result = [];
for (let i = 0; i < arr.length; i++) {
if (~arr2.indexOf(arr[i][key])) {
result[result.length] = arr[i];
}
}
const result = (function get(i, n = arr[i]) {
return n
? [].concat(arr2.includes(n[key]) ? n : [], get(-~i))
: [];
})(0);
{9}
пусть будет {4,9}
, например. Или {6,9}
. Или... Сами решайте, сколько их должно быть, вам виднее.a-z
, а a-f
.