openPopup
генерирует событие, например, popup:open
:var evt = new CustomEvent('popup:open', {
bubbles: true,
detail: 'здесь любые данные'
});
popupDOMElement.dispatchEvent(evt);
init
) подписаться на это событие:class Gallery {
init() {
popupDOMElement.addEventListener('popup:open', this.reInit.bind.this)
}
}
popupDOMElement
должен уже существовать.on
и trigger
из jQuery. методично, всерьёз и надолго погрузиться в тему
if(2 > 1) {
true
} else {
false
}
аналогичная(2 > 1) ? true : false
var a = [{
"id": "1",
"title": "Дом1"
}, {
"id": "2",
"title": "Зал2"
}, {
"id": "3",
"title": "Дом3"
}, {
"id": "4",
"title": "Зал4"
}];
for (let i of a) {
i.active = false;
}
console.log(a);
'/^\+372((( |-)?\d){8,})$/'
. const a = [ 'a', 'b', 'c', 'd' ];
const b = [ 'a', 'b', 'x', 'y', 'z' ];
const c = a.filter(n => b.indexOf(n) === -1);
// или
const c = a.filter(n => !b.includes(n));
const diff = (arr1, arr2, key = n => n) =>
arr1.filter(function(n) {
return !this.has(key(n));
}, new Set(arr2.map(key)));
const a = [
{ id: 1 },
{ id: 2 },
{ id: 3 },
];
const b = [
{ id: 1 },
{ id: 3 },
];
const c = diff(a, b, n => n.id); // [{id: 2}]