var data = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4, children: [{ id: 6 }, { id: 7, children: [{ id: 8 }, { id: 9 }] }] }, { id: 5 }];
function findById(data, id) {
function iter(a) {
if (a.id === id) {
result = a;
return true;
}
return Array.isArray(a.children) && a.children.some(iter);
}
var result;
data.some(iter);
return result
}
console.log(findById(data, 8));
import router from './router';
const app = new App({
router
});
const router = () => { /* ... */ }
export default router;
$('.col').height(heightOfTabContent + 'px');
// или
$('.col').css('height', heightOfTabContent);
class Popup{
constructor(options) {
this.modal = $(options.modal);
this.overlay = $(options.overlay);
this.overlay.on('click', this.close.bind(this));
}
open(content){
this.modal.html(content);
this.modal.addClass('open');
this.overlay.addClass('open');
}
close(){
this.modal.removeClass('open');
this.overlay.removeClass('');
}
}
function is_touch_device() {
return 'ontouchstart' in window // works on most browsers
|| navigator.maxTouchPoints; // works on IE10/11 and Surface
};