JavaScript: Exclamation Before function

I come across JavaScript code like this today:

!function(d,s,id){…}(…);

What does that !function mean?

Turns out, it is equivalent to this:

(function(d,s,id){…})(…);

The exclamation makes the function a expression. (it's the boolean “not” operator.) People do this hack to save one character worth of source code file size. Silly.

Popular posts from this blog

Browser User Agent Strings 2012

11 Years of Writing About Emacs

does md5 creates more randomness?