I used to assume that functions always go to the top of any block of JavaScript code.
For example, this works:
document.addEventListener('something', dummy); function dummy(){ console.log('dummy'); }
but this does not work and throws a ReferenceError in Firefox, but works in Chrome:
if(document){ document.addEventListener('something', dummy1); function dummy1(){ console.log('dummy'); } }
At first, I assumed that Chrome would also throw an error before I test, but somehow it works correctly. Can someone explain why it does not work in Firefox?
source share