Because callbacks behave as if they are actually placed inside a function, they are in practice closures: they can access the containing function’s variables and parameters, and even the variables from the global scope link. Right? But if I do:
function fullName(firstName, lastName, callback){
var f_scope = "X";
console.log("My name is " + firstName + " " + lastName);
callback(lastName);
}
var greeting = function(ln){
console.log('Welcome Mr. ' + ln);
console.log(f_scope);//<<---error
};
fullName("Jackie", "Chan", greeting);
In other hand if greeting
was inside of fullName
the error will not happen. So callbacks are not 100% like if they are placed inside of a function? Right?