foreach ($obj_guild['members'] as $m) {
$username = $m['user']['username'];
echo "$username - будет расстрелян<br>";
}
Есть 3 блока, которые хранятся в массиве
let block = document.querySelectorAll(".block");
const index = Array.prototype.indexOf.call(block, e.target);const index = [...block].findIndex(n => n === e.target);let index = block.length;
while (index-- > 0 && block[index] !== e.target) ;
$('blockquote').html((i, html) => html.replace(/(©)(.*)$/, '$1<cite>$2</cite>'));const el = document.querySelector('blockquote');
const html = el.innerHTML;
const index = html.indexOf('©') + 1;
el.innerHTML = `${html.slice(0, index)}<cite>${html.slice(index)}</cite>`;const el = document.querySelector('blockquote');
el.innerHTML = el.innerHTML
.split('©')
.map((n, i) => i ? '<cite>' + n + '</cite>' : n)
.join('©');
выдаёт неправильную дату
let ts = 1539338750;
data: () => ({
items: [
{ title: 'hello, world!!' },
{ title: 'fuck the world' },
{ title: 'fuck everything' },
].map(n => (n.counter = 0, n)),
}),<div v-for="n in items">
<button @click="n.counter++">{{ n.title }}</button>
<span>total: {{ n.counter }}</span>
</div>
function movie(card, ticket, perc) {
let count = 0;
let price = ticket;
let sum = card;
while (Math.ceil(sum) >= ticket * count) {
count++;
price *= perc;
sum += price;
}
return count;
}
"User.comparePassword is not a function"UserSchema.methods.comparePasswords =
(function timeout() {
if (--container.textContent > to) {
setTimeout(timeout, rand(1000, 4000));
}
})();
При этом точно такой же блок кода, но с другим свойством, отлично срабатывает и текст меняется. Отличие в том, что это другое свойство изначально есть в этом объекте campaign, а не устанавливается в created.
const arrayToObject = (array) => { array.reduce(...
return или убрать фигурные скобки.{id: '1', content: 'Some stuff'},
obj[item._id] = item
как лучше решить задачу преобразования массива в такой объект?
const arrToObj = (arr, key, val = n => n) =>
arr.reduce((acc, n) => (acc[key(n)] = val(n), acc), {});const obj1 = arrToObj(array, n => n.id);
const obj2 = arrToObj(array, n => n.id, n => n.content);
const $content = $('.video');
const $headers = $('.video-links a').on('click', function() {
const href = $(this).attr('href');
$headers.removeClass('active').filter(this).addClass('active');
$content.addClass('video-off').filter(href).removeClass('video-off');
});const content = document.querySelectorAll('.video');
const headers = document.querySelectorAll('.video-links a');
headers.forEach(n => n.addEventListener('click', onClick));
function onClick({ target: t }) {
const href = t.getAttribute('href');
headers.forEach(n => n.classList.toggle('active', n === t));
content.forEach(n => n.classList.toggle('video-off', !n.matches(href)));
}
array_map(function($n) {
return [
'date' => $n[0],
'sum' => $n[1]
];
}, array_chunk($arr, 2))
<img src={data.url} key={data.url} width="100%" alt="" />
arr1.filter(n => arr2.includes(n)).length !== 0
// или
arr1.some(function(n) {
return this.has(n);
}, new Set(arr2))
// или
new Set([ ...arr1, ...arr2 ]).size < new Set(arr1).size + new Set(arr2).size!!new Set(arr1).intersection(new Set(arr2)).size