const lowered = str.toLowerCase();
const filtered = data.filter(n => !n.name.toLowerCase().indexOf(lowered));
const filtered = data.filter(function(n) {
return n.name.toLowerCase().startsWith(this);
}, str.toLowerCase());
const filtered = data.filter(((reg, n) => reg.test(n.name)).bind(null, RegExp(`^${str}`, 'i')));
чтобы числа повторялись не более двух раз
SELECT *, price * ((100 - discount) / 100) AS discounted
FROM prices
ORDER BY discounted
LIMIT 10
$(document).on({
focus() {
$(this).addClass('active-amount-input');
},
blur() {
$(this).removeClass('active-amount-input');
},
}, '.amount, .amount_1');
$(document).on('focusin focusout', '.amount, .amount_1', e => {
$(e.currentTarget).toggleClass('active-amount-input', e.type === 'focusin');
});
- <main className={active ? 'move-to-left' : ''}>
+ <main>
- <div className="sidebar">
+ <div className={'sidebar ' + (active ? 'move-to-left' : '')}>
- <NavRight onClick={this.toggleActive} buttonClass={!active ? 'active' : ''} navClass="hidden-xs" />
+ <NavRight onClick={this.toggleActive} buttonClass={active ? 'active move-to-left' : ''} navClass="hidden-xs" />
+ body {
+ overflow: hidden;
+ }
.sidebar {
...
- z-index: 1;
- right: 0;
+ z-index: 3;
+ right: -400px;
+ transition: all .7s ease;
Имелось в виду, что контент тоже двигается при смещении sidebar, но не убегает полностью в левый угол, а остается по центрy оставшейся ширины
TS2362 The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum
this.endDate - this.currentDate
+this.endDate - +this.currentDate
const uniqueDocs = docs
.filter((n, i, a) => n === a.find(m => m.date === n.date && m.type === n.type))
.map(({ type, date }) => ({ type, date }));
const uniqueDocs = Object
.entries(docs.reduce((acc, n) => ((acc[n.type] = acc[n.type] || new Set).add(n.date), acc), {}))
.reduce((acc, n) => (acc.push(...Array.from(n[1], m => ({ type: n[0], date: m }))), acc), []);
const unique = (arr, keys) =>
arr.filter((n, i, a) => i === a.findIndex(m => keys.every(k => n[k] === m[k])));
const pick = (obj, keys) =>
keys.reduce((acc, k) => (acc[k] = obj[k], acc), {});
const keys = [ 'type', 'date' ];
const uniqueDocs = unique(docs, keys).map(n => pick(n, keys));
obj() {
return this.items[0];
},
<div v-if="obj">
<div v-for="(val, key) in obj">
...
$('.shop-ellement-sidebar').on('click', function(e) {
if ($(e.target).closest('.element-sidebar_content').length) {
return;
}
// дальше проверка наличия класса active и т.д. - без изменений
.element-sidebar_content
:$('.element-sidebar_content').click(function(e) {
e.stopPropagation();
});