I understand that in Javascript a function can return another function and it can be called immediately. But I don't understand the reason to do this. Can someone please explain the reason and benefit why you might want to do this in your code? Also, is the function that returns 'hello' considered a closure?
function a () {
return function () {
console.log('hello');
}
}
//then calling the function
a()();