document.body.addEventListener('click', e => {
if(e.target.matches('.super-selector')) {
// e.target - кликнутый элемент
}
})
Array.prototype.myUnshift = function(...args) {
return [...this, ...args]
}
[3,5].myUnshift(34,52,25)
// [3, 5, 34, 52, 25]
html = ''
for (key in result.category) {
html += `<p>${key}</p><select>`
for (key1 in result.category[key].family) {
html += `<option>${key1}</option>`
}
html += `</select>`
}
var obj = {
counter: 0,
get count() {
this.counter++
return this.counter
}
}
console.log(obj.count, obj.count, obj.count)
// 1 2 3
function compoundMatch(words, target) {
for (let i = 0; i < words.length; i++) {
for (let ii = 0; ii < words.length; ii++) {
const m1 = words[i] + words[ii] === target
const m2 = words[ii] + words[i] === target
if (i !== ii && (m1 || m2)) {
const arr = m1 ? [i, ii] : [ii, i]
return [words[i], words[ii], arr]
}
}
}
return null
}
const SuperLink = (props) => <NavLink activeClass="active" activeStyle={{fontWeight: "bold"}} to={props.to}>{props.text}</NavLink>
....
<SuperLink to="/stats" text="Stats"/>