I have some experience with javascript already, but I have a doubt for quite a while: why can't you pass a named function to places where it is expected an anonymous function to execute a piece of code? ie:
document.getElementById('btn').addEventListener('click', function(){
alert('Hello World');
});
Now let's say I already have a function that does this.
var func = function(){
alert('Hello World');
}
Why it isn't executed as a callback to the click event?
document.getElementById('btn').addEventListener('click', func);
it seems redundant to create a anonymous function to then call a named function:
document.getElementById('btn').addEventListener('click', function(){
func();
});