I have two examples of simple closures and my question is that when should I return the function with or without the bracket? Thank you!
Example 1:
function names (first, last) {
var intro = "My name is ";
function full_Name () {
return intro + first + " " + last;
}
return full_Name(); <----
}
full_Name("Macro","phages"); // My name is Macro phages
Example 2:
function names (first) {
var intro = "My name is ";
function full_Name (last) {
return intro + first + " " + last;
}
return full_Name; <---- why not full_Name();
}
var white_cells = names("Macro");
white_cells("phages"); // My name is Macro phages