const [ first, ...rest ] = document.querySelectorAll('[type="checkbox"]');
const onChange = () => first.checked = rest.every(n => n.checked);
first.addEventListener('change', () => rest.forEach(n => n.checked = first.checked));
rest.forEach(n => n.addEventListener('change', onChange));