tbny1,
вариант ...
(function(){
'use strict';
class Menu {
constructor(settings) {
this.clsMenuButton = settings.clsMenuButton;
this.nodeMenu = settings.nodeMenu
this.nodeMenu.addEventListener('click', this.toggle.bind(this));
}
toggle(event) {
if(event.target.closest(this.clsMenuButton)){
event.preventDefault();
this.nodeMenu.classList.toggle('js-menu_activated');
}
else this.nodeMenu.classList.remove('js-menu_activated');
}
}
let nodeMenu = document.querySelector('body');
new Menu({
nodeMenu: nodeMenu,
clsMenuButton: '.js-menu__toggle'
});
})();