Given the code:
function stuff() {
console.log('stuffing');
}
stuff = stuff;
stuffy = () => stuff();
stuffx = () => console.log('tobi');
function stuffers(stuff = stuffx) {
stuff();
stuffy();
}
stuffers();
The result is what one would expect:
tobi
stuffing
But when changing the stuffers function signature like this:
function stuff() {
console.log('stuffing');
}
stuff = stuff;
stuffy = () => stuff();
stuffx = () => console.log('tobi');
function stuffers(stuff = stuff) {
stuff();
stuffy();
}
stuffers();
The result is:
ReferenceError: stuff is not defined
Why is this happening ONLY in the case of having the same name?