str := "Gigabyte GA-B250M-DS3H (1,485)MSI B250M PRO-VD (MS-7A74) (1,199)MSI H110M PRO-VH PLUS (MS-7A15) (946)Asus H110M-K (816)Asrock B250M-HDV (807)MSI B250M PRO-VDH (MS-7A70) (667)MSI H110M PRO-VD (MS-7996) (663)"
reg, _ := regexp.Compile("\\(.*?\\)")
str = reg.ReplaceAllString(str, "")
const compareArrays = (a, b) => a.length === b.length && a.every((n, i) => n === b[i]);
+str.replace(/[^\d.]/g, '')
parseFloat(str.match(/[\d.]/g).join(''))
arr.reduceRight((_, n, i, a) => indexes.includes(i) && a.splice(i, 1), null);
// или
[...indexes].sort((a, b) => b - a).forEach(i => arr.splice(i, 1));
// или
arr.splice(0, arr.length, ...arr.filter((n, i) => indexes.indexOf(i) === -1));
const newArr = arr.filter(((indexes, n, i) => !indexes.has(i)).bind(null, new Set(indexes)));
<Transactions />
class="filter-menu"
{transaction}
<div>{transaction.type}</div>
<div>{transaction.date}</div>
useEffect(() => {
const onKeypress = e => console.log(e);
document.addEventListener('keypress', onKeypress);
return () => {
document.removeEventListener('keypress', onKeypress);
};
}, []);
const Comments = ({ items }) =>
Array.isArray(items) && items.length
? <React.Fragment>{items.map(n =>
<div className="comment" key={n.id}>
<h3>{n.name}</h3>
<div>{n.body}</div>
<Comments items={n.reply} />
</div>)}
</React.Fragment>
: null;
async function request(data) {
let result = data;
do {
result = await запрос(result);
} while (result не тот, который нужен);
return result;
}
function requestRecursive(data) {
return запрос(data).then(result => {
return result тот, который нужен
? result
: requestRecursive(result);
});
}
const values = Object.values(obj);
const count = values.flat().length;
// или
const count = [].concat(...values).length;
// или
const count = values.reduce((acc, n) => acc + n.length, 0);
// или
const count = eval(values.map(n => n.length).join('+')) || 0;
a = [ 1, 2, 3 ];
b = [ 4, 5, 6 ];
c = a;
// здесь должен быть какой-то код
console.log(a); // [ 4, 5, 6 ]
console.log(b); // [ 1, 2, 3 ]
console.log(a === c); // true
b.splice(0, b.length, ...a.splice(0, a.length, ...b));
const index = myCollection.indexOf(e.get('target'));
alert(myCoords[index].text);
data: () => ({
image: 0,
images: [ 'раз картинка', 'два картинка', 'три картинка' ],
}),
<button v-for="(n, i) in images" @click="image = i">
Показать картинку #{{ i }}
</button>
<transition name="image" mode="out-in">
<img :key="image" :src="images[image]">
</transition>
.image-enter-active,
.image-leave-active {
transition: opacity .3s;
}
.image-enter,
.image-leave-to {
opacity: 0;
}
const filteredProducts = [
[ true, n => n.type === 'Bras' ],
[ true, n => n.price <= tempPrice ],
[ color !== 'all', n => n.color === color ],
[ cup, n => n.cup.includes(cup) ],
[ shipping, n => n.freeShipping === true ],
[ search, n => n.title.toLowerCase().startsWith(search.toLowerCase()) ],
].reduce((products, [ active, fn ]) => {
return active
? products.filter(fn)
: products;
}, storeProducts);
this.setState({ filteredProducts });
Вариант добавить в лоб, как я сделал это выше class='test', не сработал.
Этот класс применился к input. А мне нужно применить класс к самому select, который появляется перед закрывающим тегом body.