Your example is a (named) Function Expression.
The difference Between the two is in how the browser loads them.
Function declarations are loaded before any code is executed.
Function expressions are loaded only when the interpreter reaches that line of code.
This means:
abc();
var abc = function() {
console.log("Wait! What??");
}
Won't work, but:
def();
function def() {
console.log("Wait! What??");
}
Will.
Now in your example, you can access def
, but only inside the function itself.
var abc = function def() {
console.log(def);
}
abc();
// Logs:
//function def() {
// console.log(def);
//}