3 ms·
The primary difference is "hoisting" https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#var_hoisting https://developer.mozilla.org
by yawboakye 13y ago
The primary difference is "hoisting" https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#var_hoisting https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe.... Closure can be created in both cases.
Also, functions have names.
var funcName = function () {};
funcName.name; // ""
function func2() {};
func2.name; // "func2"
Thus, anynomous functions are truly anonymous whether or not they're assigned to a variable. `func2` can be assigned to a variable too. It'd retain its name (`func2`).