str.replace(/:$/, '')
// или
/(.*?):?$/.exec(str)[1]
// или
str.match(/[^:]+:[^:]+/)[0]
// или
str.split(':', 2).join(':')
// или
str.slice(0, str.slice(-1) === ':' ? -1 : void 0)
// или
str.substring(0, str.length - !!-~str.search(':$'))
$('.progress__item').each(function() {
const $this = $(this);
const $progressBar = $this.find('.progress__bar');
const $value = $this.find('.progress__value');
const value = $progressBar.data('progress-value');
$progressBar.width(`${value}%`);
$({ value: 0 }).animate({
value,
}, {
duration: 1000,
step: val => $value.text(`${val.toFixed(1)} %`),
});
});
пишу я на Vue, и к сожелению пока неочен хорошо знаком с Vue, поетому пока затрудняюсь подключить сей плагин
let result = '';
for (const k in obj) {
if (obj.hasOwnProperty(k)) {
result += (result && '&') + k + '=' + obj[k];
}
}
// или
const result = Object.entries(obj).map(n => n.join('=')).join('&');
// или
const result = `${new URLSearchParams(obj)}`;
m => `<span style="background: red;">${m}</span>`'<span style="background: red;">$&</span>'const p = document.querySelector('.resultParagraph');
document.querySelector('.input').addEventListener('keypress', e => {
if (e.key === 'Enter') {
const regex = RegExp(e.target.value, 'gmi');
const replacement = '<span style="background: red;">$&</span>';
p.innerHTML = p.textContent.replace(regex, replacement);
}
});
36 / SQ(6)? - Правильно думаете, единице.36.
$('.selectpicker')
data: () => ({
items: Array.from(
{ length: 5 },
(_, i) => Array.from(
{ length: 5 },
(_, j) => i * 5 + j
)
),
active: null,
}),
watch: {
active(val) {
if (val) {
this.$nextTick(() => this.$refs.input[0].focus());
}
},
},<table>
<tr v-for="(row, iRow) in items">
<td v-for="(val, iCol) in row" @click="active = { iRow, iCol }">
<input
v-if="active && active.iRow === iRow && active.iCol === iCol"
v-model="row[iCol]"
@keypress.enter="active = null"
ref="input"
>
<template v-else>{{ val }}</template>
</td>
</tr>
</table>
flat = [ n for m in united_scores for n in m ]
ids = set(n['id'] for n in flat)
grouped = [ { 'id': n, 'score': sum(m['score'] for m in flat if m['id'] == n) } for n in ids ]
хочу, чтобы в переменной theme лежало значение state.theme, но по факту получается так: theme.theme
export const theme = (state = 'light', action) => {
switch (action.type) {
case constants.CHANGE_THEME:
return action.payload;
default:
return state;
}
};