functions are data in memory stack, so when you define another function with the same name, it overrides the previous one.
The second definition of an Object overwrites the first one. In general the last definition of an object overwrites all previous definitions.
Functions in JavaScript are Objects
https://stackoverflow.com/questions/33973987/why-am-i-able-to-define-same-function-twice-in-javascript