const getDateOfNearestDay = (day, date = new Date()) =>
new Date(
date.getFullYear(),
date.getMonth(),
date.getDate() + ((7 + day - date.getDay()) % 7)
);
const dateOfNearestSaturday = getDateOfNearestDay(6);
получаю ошибку
вызываю в дочернем компоненте this.props.getCity(1, 'П')
getCity={this.getCity}
, при этом метод getCity в родительском компоненте отсутствует. Есть getCities. Это как?передается пустой токен
{this.state.token && <NewAdvert id="newadvert"
user={this.state.fetchedUser}
cities={this.cities}
getCities={this.getCities}
getCity={this.getCity}
token={this.state.token}
getToken={this.getToken}
go={this.go}
/>}
Предполагается, что когда пользователь нажмет на фильтр, у меня вызовется функция setRouter...
.push(item)
на .push(+item)
(или .push(Number(item))
, или .push(parseInt(item))
). Соответственно, надо сделать числом и search - для этого достаточно добавить соответствующий модификатор v-model..sort()
на .sort((a, b) => a - b)
.computed: {
array() {
return this.info
.split(';')
.map(n => parseInt(n))
.filter(n => !Number.isNaN(n))
.sort((a, b) => a - b);
},
},
const values = Object.values(arr.reduce((acc, n) => {
const t = acc[n.from];
acc[n.from] = (t && t.to > n.to) ? t : n;
return acc;
}, {})).map(n => n.val);
const values = Object.values(arr.reduce((acc, n) => {
(acc[n.from] = acc[n.from] || [])[n.to] = n.val;
return acc;
}, {})).map(n => n.pop());
const values = [...arr]
.sort((a, b) => (a.from - b.from) || (a.to - b.to))
.filter((n, i, a) => !a[i + 1] || a[i + 1].from !== n.from)
.map(n => n.val);
Можно с помощью lodash.
const values = _
.chain(arr)
.groupBy('from')
.map(n => _.maxBy(n, m => m.to).val)
.value();
$(document).on('input', '.price-item', function() {
const min = +$('.min-price').val() || 0;
const max = +$('.max-price').val() || Infinity;
$('.filter')
.hide()
.filter(function() {
const val = parseFloat($('.price', this).text());
return min <= val && val <= max;
})
.show();
});
$('div.award a').each((i, n) => n.onmouseover = n.onmouseout = null)
$('div.award a').removeAttr('onmouseover onmouseout')
$('div.award a').prop({
onmouseover: null,
onmouseout: null,
})
$('table td:nth-child(1)').html((i, html) => `<a href="?name=${html}">${html}</a>`);
document.querySelectorAll('tbody tr').forEach(n => {
const td = n.children[0];
const text = td.textContent;
td.innerHTML = `<a href="?name=${text}">${text}</a>`;
});
for (const { cells: [ n ] } of document.querySelector('tbody').rows) {
const text = n.innerText;
n.innerHTML = `<a href="?name=${text}">${text}</a>`;
}
const exclude = [ 'class1', 'class2', 'class3' ];
Array
.from(document.querySelectorAll('div a'))
.filter(n => !exclude.some(m => n.classList.contains(m)))
.forEach(n => n.style.display = 'none');
Буду безмерно рад любым советам
Вопрос был поставлен в как раз таки из-за того, что я "умею гуглить", но, к сожалению, в силу отсутствия опыта выделить полезную информацию из информационного шума довольно сложно.