`var x` gets "hoisted" which means it has the legal value of "undefined" until an expression sets its value in the order of execution. Its value can be assigned to anything (a number,string,boolean, function, object... ) any number of times within the var statements scope ( the containing object usually ).
`var x = function(){..}` is exactly the same as `var x; x=function(){...}`
And the `var x;`is part is "hoisted" to the beginning, the `x=fun..` part doesnt happen till it runs, and `x=other` can happen before.
Its easy to write `var i = something`and then some lines later write `var i = someother`the second `var` is just ignored, the same `i` gets
assigned to.
`function y()` is available before any order of execution.
console.log( "y() returns:", y() )
if (false){ function y(){return 1} } //never execs but function exists
console.log( "x is now:", x ) //is "undefined" not yet set
// console.log( "z is now:", z ) //this would break the script
if (true) { x=3 } // x happens to get set here
console.log( "x is now:", x ) //3
if (false){ var x=x||2 } //x is hoisted by var regardless if true or false
console.log( "x is now:", x )
// outputs ...
y() returns: 1
x is now: undefined
x is now: 3
x is now: 3
Beyond the differences in initialization I don't recall any practical differences in handling them, though there may be rare gotchas.
I prefer to use function x() and export as a property later if needed.