Hoisting is a feature in JavaScript which allows access to function declarations before they’re defined
This means that we can place a function call before our function declaration and everything will still work as expected
// Calling greetWorld() BEFORE it's function declararion
greetWorld()
// declaration of greetWorld()
function greetWorld() {
console.log('Hello, World!')
}
Notice how hoisting allowed greetWorld()
to be called before the greetWorld()
function was defined
This is not considered a best practice, but you should be aware that the feature exists