In a very common code example on Javascript event delegation https://javascript.info/event-delegation, I'm confused about where the variable "menu" comes from on line 40 in http://plnkr.co/edit/91Q9jINXlue2fXiB0fAY?p=preview. The variable is passed to the constructor, yet is never initialized. It appears the variable "menu" automatically is created from this div element:
<div id="menu">...</div>
<script>
...
new Menu(menu); /* Who initializes "menu".
...
</script>
I've been doing Javascript for a long time yet this is really confusing to me. I also am not sure how to generalize this question.
Normally I would do a document.getElementById("menu") to get the div element. Where do these variables get initialized and how can I find out more about variables like these? Is there a spec?