The answer is called "hoisting," a JavaScript behaviour that occurs when function and variable declarations are pushed to the top of their contained scope during compilation.
In JavaScript, the 'this' keyword alluded to the active execution context is dynamically determined. Understanding function invocation and object-oriented programming is greatly aided by it.
Arrow functions, destructuring assignments, template literals, and the let/const keywords for variable declarations are just a few of the improvements that ES6 brought.