Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 7
    For the sake of clarity for readers who may want to use an assignment with an immediately invoked function your example code var myVar = !function(){ return false; }() could omit the ! like var myVar = function(){ return false; }() and the function will execute correctly and the return value will be untouched. Commented Mar 11, 2013 at 0:55
  • 1
    To be clear, you can use it once to coerce to Boolean, because it's a logical not operator. !0 = true, and !1 = false. For JavaScript minification purposes, you'd want to replace true with !0 and false with !1. It saves 2 or 3 characters. Commented Jul 26, 2015 at 1:07