The onclick="addFruit" calls an instance method between the inner script tags. Similar to how JS would call a global window.addFruit with a similar syntax.
Keyword being "similar", as in, not the same. Its neither the behaviour of html onclick attribute, nor dom onclick attribute.