obj?.prop // optional property access
obj?.[expr] // ditto
func?.(...args) // optional function or method call
new C?.(...args) // optional constructor invocation
function checkProps(obj, props) {
if (!obj) return false;
let value = obj;
for (let i = 0, l = props.length; i < l; i++) {
value = value[props[i]];
if (value == null) return false;
}
return true;
}
if (checkProps(campaign, ['budget', 'bills', 'type'])) {}
const isAllUnique = (...args) => new Set(args).size === args.length;
console.log(isAllUnique(69, 187, 666)); // true
console.log(isAllUnique(2, 2, 3, 4)); // false
console.log(isAllUnique(...'ABCDA')) // false
document.addEventListener('click', function(e) {
if (!e.target.closest('.tileset-showitems')) {
tilesetShowListRemove();
}
});
- .active {
+ .active .box {
const containerSelector = '.tileset-showitems';
const buttonSelector = `${containerSelector} .tileset-showitems-trigger`;
const activeClass = 'active';
const closeAllExcept = container => document
.querySelectorAll(`${containerSelector}.${activeClass}`)
.forEach(n => n !== container && n.classList.remove(activeClass));
document.addEventListener('click', ({ target: t }) => {
const button = t.closest(buttonSelector);
const container = t.closest(containerSelector);
if (button) {
container.classList.toggle(activeClass);
}
closeAllExcept(container);
});
window.addEventListener('keydown', e => e.key === 'Escape' && closeAllExcept());
const data1 = await promise1();
const data2 = await promise1();
//....
Promise.all([
promise1(),
promise1()
])
.then(() => {
//....
})
Проблема в реактивности, при изменении текстов в инпуте, меняются старые записанные обьекты
state.filter_list.push({ ...state.filter })