Long time listener, first time asker.
I'm following a tutorial and we have the following code:
const closeModal = function () {
modal.classList.add('hidden');
overlay.classList.add('hidden');
};
overlay.addEventListener('click', closeModal);
document.addEventListener('keydown', function (e) {
console.log(e.key);
if (e.key === 'Escape' && !modal.classList.contains('hidden')) {
**closeModal();**
}
});
My question is when do I need a ( ) to explicitly call a function? In the first case I don't need it, but in the second case I do. I tried running it without the ( ) but it didn't work.
Thanks for the help and any terminology would be useful. I tried google searches but didn't know the right keywords to use.