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*

5
  • 38
    This is so misleading, it doesn't make anything parseable, it makes a function declaration be parsed as an expression, that evaluates to the function itself, allowing it to be called. Commented Jun 8, 2013 at 18:29
  • I actually think "unparseable" is accurate - the js vm will not parse the first example. Commented Feb 19, 2020 at 20:59
  • @JeffHykin Your comment is interesting and entertaining. I will, however, point out that it should say "unary" ;) Commented Dec 5, 2020 at 22:13
  • 1
    To add some clarity (adding to @michelpm's point) both +function(){}(); and -function(){}(); also work because + and - can be unary operators. However ! is preferable since it is only a unary operator, while + and - can be both binary and unary operators. Commented Dec 7, 2020 at 11:43
  • Wow that's embarrassing on my part, thank you @valid. It's a shame Stack Overflow doesn't let comments be edited after 5 min. That one was worth deleting and fixing. Commented Dec 7, 2020 at 11:47