const pet = function (name) { // The outer function defines a variable called "name"
const getName = function () {
// The inner function has access to the "name" variable of the outer function
return name;
}
return getName; // Return the inner function, thereby exposing it to outer scopes
}
const myPet = pet('Vivie');
myPet(); // Returns "Vivie"
----------------------------->I fix this two ways<---------------------------------------
That one above was return getName and I replace for return getName()
----------------------------->Second way<---------------------------------------
Was write const myPet = pet('Vivie'); and I replace for const myPet = pet('Vivie')();
myPet() is an object? So we find a rotten potato of an object that has a parenthesis like a function... do the work but the reason is still of a function so is a hybrid object that appears with a function. Scope is like
Rute Bezerra de Menezes Gondim
No comments:
Post a Comment