I know this is stupid, but there is a difference between this:
(function() { var foo = 'bar'; })();
and this?
(function() { var foo = 'bar'; }());
JSLint tells us Move the invocation into the parens that contain the function , but I don't see the need.
Edit: The answers are too cool. ~function , an alternative to JSHint , as well as jQuery preference for (/***/)(); and Crockford's explanation! I thought that I was going to just get the answer "they are the same."
You guys decide the best option with upvotes, and I mark it.
javascript closures comparison jslint anonymous-function
Camilo Martin Jan 08 2018-12-12T00: 00Z
source share