Personally, I use a linter to catch hoisting mistakes.
I don’t understand why everyone in this thread has been saying that. Function declarations are absolutely reassignable.
function f() {
console.log('f');
}
f = function() {
console.log('f2');
}
f(); // f2
That being said, for the sake of our code being understandable, we shouldn’t reassign functions, regardless if it’s a function expression or declaration.
What if someone tries to call removeEvent before addEvent?