This is a concept called callbacks in Vue.js. This concept says that
" The point is that functions in JavaScript are like any other data type. They can be created at any time, set to a variable, and reassigned. It shouldn’t be a surprise then that they can be passed into another function and returned from another function. "
function fnGenerator() {
return function() {
console.log(‘Ran the inner function’);
}
}
const fnReturned = fnGenerator();
console.log(fnReturned); // → [Function]
fnReturned(); // → Ran the inner function
It’s a code snippet from vue.js, can some explain how it works,
I don’t understand how it works when they call the function renamed with a const fnReturned();