Function declare as a variable?

Function declare as a variable?
0

#1

What is the difference b/w these two function declaration:

let stop = function(){
   console.log('s');
}

&

function stop(){
  console.log('s');
}

#2

they’re both called the exact same way and do the exact same thing…
but I think if you want to change what ‘stop’ is , that is, if you want to change the stop function dynamically in the code, the first method is the only way to do it because you can later say:

stop = function(newParam) {
console.log(newParam);
}


#3

No, I can still assign a new function to stop using the conventional function declaration.

function stop(){
  console.log('s');
}
stop(); // displays 's'

stop = function(newParam) {
console.log('t');
}
stop(); // displays 't'

The biggest difference is, in the first example, you can not call the stop function before it is defined. In the second example, you can still call it, because of hoisting.
So the following will work:

stop(); //  displays 's'

function stop(){
  console.log('s');
}

but the following will error out, because stop is not defined yet.

stop();  // causes a reference error

let stop = function(){
   console.log('s');
}