This question already has an answer here:
I was looking at this very cool snippet and i came across this weird line in the js and deleting that prevent the function from being invoked
!+-+-+!+-+-+!+-+-+!+-+-+!+-+-+!+-+-+!+-+-+!+-+-+!
function(d, w){
...
}(document, window);
,i wrapped the function with ( ) as it supposed to be and it works as intended.
(function(d, w){
...
})(document, window);
so my question is what is that weird line and why does it work? my wild guest is that it is some kind IIFE...
!
operator tricky .. ! – rab Apr 23 '13 at 13:21+
,-
, and!
are all unary operators doing the same thing as the lone!
in the linked duplicate. – apsillers Apr 23 '13 at 13:21+
,-
, or!
is needed for the function to be parsed as a function expression (rather than a function declaration). – apsillers Apr 23 '13 at 15:39