str.split('/').pop()
//или
str.slice(str.lastIndexOf('/') + 1)
// или
[...str].reduce((acc, n) => n === '/' ? '' : acc + n, '')
str.match(/[^\/]*$/)[0]
// или
str.replace(/.*\//, '')
max(array_map(function($n) {
return $n['ask']['c'];
}, $obj['candles']))
max(array_column(array_column($obj['candles'], 'ask'), 'c'))
:value="name"
.v-for="(name, i) in names"
, v-model="checkboxValue[i]"
. NOT IN я так понял https://w3resource.com/mysql/comparision-functions... работает начиная с 5.6
arr.map((n, i) => n ? i : null).filter(n => n !== null)
// или
arr.map((n, i) => n ? i : NaN).filter(n => n === n)
// или
arr.map((n, i) => !!n && i).filter(Number.isInteger)
// или
arr.map((n, i) => !n || i).filter(n => n !== !0)
arr.reduce((acc, n, i) => n ? [ ...acc, i ] : acc, [])
// или
arr.reduce((acc, n, i) => (n && acc.push(i), acc), [])
for (let i = arr.length; i--;) {
if (arr[i]) {
arr[i] = i;
} else {
arr.splice(i, 1);
}
}
// или
arr.reduceRight((_, n, i, a) => n ? a[i] = i : a.splice(i, 1), 0);
// или
arr.splice(0, arr.length, ...любое_выражение_с_map/filter_или_reduce_из_показанных_выше);
// или
let count0 = 0;
for (const [ i, n ] of arr.entries()) {
arr[i - count0] = i;
count0 += !n;
}
arr.length -= count0;
data: JSON.stringify({ action: 'get_genres' })
json_decode($_POST['action'])
json_decode(file_get_contents('php://input'), true)['action']
<button data-move="-10,0">left</button>
<button data-move="10,0">right</button>
<button data-move="0,-10">up</button>
<button data-move="0,10">down</button>
<button data-move="10,10">right down</button>
<button data-move="20,-5">fast right slow up</button>
$(document).on('click', '[data-move]', function() {
const [ dx, dy ] = this.dataset.move.split(',').map(Number);
$('#overlay')
.css('left', (i, val) => `${parseInt(val) + dx}px`)
.css('top', (i, val) => `${parseInt(val) + dy}px`);
});
// или, к чёрту jquery
document.addEventListener('click', e => {
const { move } = e.target.dataset;
if (move) {
const block = document.querySelector('#overlay');
const { left, top } = getComputedStyle(block);
const [ dx, dy ] = move.split(',').map(n => +n);
block.style.left = parseInt(left) + dx + 'px';
block.style.top = parseInt(top) + dy + 'px';
}
});
v-for="post in posts.slice(0, определённое количество)"
const $block = $('.block_to_add').clone();
$('.click_to_add_block').click(function() {
$(this).before($block.clone());
});
А подскажите, как удалить один из блоков по клику на другую кнопку?
$(document).on('click', '.delete', function() {
$(this).parent().remove();
});
<button class="delete">удалить</button>
v-show="showDocs"
. Обработка клика станет выглядеть так: @click="showDocs = !showDocs"
.style.display
вовсе не none, а пустая строка (скорее всего - вы ведь элемент через css изначально скрываете, да?).Так не получиться, так как вывожу элементы в цикле v-for.
$grouped = [];
foreach ($date as $d) {
$parts = explode('-', $d);
$grouped[$parts[0]][intval($parts[1])][] = intval($parts[2]);
}
data: () => ({
checked: null,
items: [ 'hello, world!!', 'fuck the world', 'fuck everything' ],
}),
<label v-for="(n, i) in items">
<input
type="checkbox"
:checked="checked === i"
@change="checked = $event.target.checked ? i : null"
>
{{ n }}
</label>