It works because it is correct JavaScript syntax. You cannot pass a function as a parameter with parameters in the syntax that you used. If you need to pass a function as a parameter with parameters you need to wrap it inside of another function, or use the 'evil' eval method.
Both of these will work equally:
map.on('zoomend', onZoomend);
or
map.on('zoomend', function() { onZoomend(); });
Look up passing a function as an argument/parameter to read up on it further.