Are these 2 JavaScript code snippets equivalent?
jQuery(document).ready(function() {
(function(){
return 'something';
})();
});
and this
jQuery(document).ready(function() {
return (function() {
return "something";
})();
});
I was trying coffescript. Converting the above first code to coffescript and converting it back to JS gives the second snippet. So, I wanted to know if they are exactly same. Isn’t returning a function from within a function related to closures?
They’ll be the same, yeah. Except that the second one is going to use 1 more unit of stack memory.