когда нажимаю повторно чтобы остановить музыку, она не останавливается
const result = arr
.reduce((acc, n, i, a) => (
a[i - 1] !== n && acc.push([ n, 0 ]),
acc[acc.length - 1][1]++,
acc
), [])
.map(([ v, c ]) => c === 1 ? v : Array(c).fill(v));
const result = arr
.reduce((acc, n, i, a) => (
a[i - 1] === n || acc.push([]),
acc[acc.length - 1].push(n),
acc
), [])
.map(n => n.length === 1 ? n[0] : n);
const result = arr.reduce((acc, n, i, a) => {
const prev = n === a[i - 1];
const next = n === a[i + 1];
!prev && next && acc.push([]);
(prev || next ? acc[acc.length - 1] : acc).push(n);
return acc;
}, []);
const length = 48;
const step = 30;
const locale = 'en-US';
const options = {
hour: '2-digit',
minute: '2-digit',
};
const times = Array.from({ length }, (_, i) => {
return new Date(0, 0, 0, 0, step * i).toLocaleTimeString(locale, options);
});
// или
const times = Array.from({ length }, function() {
return this[1].format(this[0].setMinutes(this[0].getMinutes() + step));
}, [ new Date(0, 0, 0, 0, -step), new Intl.DateTimeFormat(locale, options) ]);
u
:preg_match_all("/[а-я]{4,}/ui", $string, $keywords);
использую известный компонент vue-select он довольно удобный но у него нет того что мне нужно, а именно отображения опций в виде html-кода а не текста
data: () => ({
index: 0,
items: [
[ 'hello, world!!', 'fuck the world', 'fuck everything' ],
[ '69', '187', '666' ],
[ '!!!', '???', ':::' ],
[ '+++', '***', '///' ],
],
}),
<ul v-if="index < items.length" @click="index++">
<li v-for="n in items[index]">{{ n }}</li>
</ul>
<button v-else @click="index = 0">давай заново</button>
[...`${num}`].map(Number)
num.toString().split('').map(n => +n)
Array.from(String(num), parseFloat)
('' + num).match(/./g).map(n => parseInt(n))
Object.values(num.toFixed()).map(n => ~~n)
[].map.call(/.+/.exec(num)[0], n => n * 1)
eval('['.concat(num, ']').replace(/\d/g, '$&,'))
Object.assign([], JSON.stringify(num)).map(JSON.parse)
Array(1 + (Math.log10(num) | 0)).fill().map((n, i) => (num / 10 ** i | 0) % 10).reverse()
((f = (x, a) => (a.unshift(x % 10), x = x / 10 | 0, x ? f(x, a) : a)) => f(num, []))()
Нужно как-то парсить полученный html...
const data = {
[name]: value,
};
const data = Object.fromEntries([ [ name, value ] ]);
logOut () {
onConfirm={this.logOut}
<table>
<tr>
<td><div class="draggable">0</div></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td><div class="draggable">1</div></td>
<td><div class="draggable">2</div></td>
</tr>
<tr>
<td></td>
<td><div class="draggable">3</div></td>
<td></td>
</tr>
</table>
td {
border: 1px solid silver;
width: 100px;
height: 100px;
}
.draggable {
display: inline-block;
width: 25px;
height: 25px;
background: red;
cursor: pointer;
margin: 5px;
color: white;
}
$('.draggable').draggable({
containment: 'table',
stop(e, ui) {
$(this).css({
left: '',
top: '',
});
},
});
$('td').droppable({
accept: '.draggable',
drop(e, ui) {
ui.draggable.appendTo(this);
},
});