I know that there are 3 ways of creating functions
Function Declaration. Function Expression. Arrow Function.
function foo(){
console.log("boo");
{
and
var foo = function(){
console.log("boo");
}
I know that the first one is hoisted so that even if we call it before the function it will work. For the second one because it is an assigned variable hoisting will not work.
My question why is there such a requirement? I just started learning JS and it does not make sense to me yet to set the difference between those two.
Also how about Arrow Function? Why do we need it as well?
Thank you
Edit1: I found my answer for the question of Arrow Functions which seems too advanced for me. I will review it as I go.
When should I use arrow functions in ECMAScript 6?
I am still not clear about the difference between Function Declaration and Function expression.