There is a difference between a function declaration and a function expression.
Functions defined using an expression are not hoisted.
You can read more here: w3schools.com/js/js_function_defin...
Check all of types and try to understand it correctly ;-)
function test() {}
const test = function() {}
const test = () => {}
(function () { var test = 1; })();
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There is a difference between a function declaration and a function expression.
Functions defined using an expression are not hoisted.
You can read more here: w3schools.com/js/js_function_defin...
Check all of types and try to understand it correctly ;-)
function test() {}
const test = function() {}
const test = () => {}
(function () {
var test = 1;
})();