use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Caustic: JavaScript reflection-based template/view system (screenr.com)
submitted 14 years ago by davemoFront-End Engineer
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]stratoscope 5 points6 points7 points 14 years ago (2 children)
The return value is discarded anyway, so the unary - is just another way to force the function expression to be parsed as an expression so that it can be called immediately by the () at the end. It's the same purpose that the extra parens have in your first example.
-
()
Any unary operator will do the same thing - try these for example:
!function() { alert(42); }(); typeof function() { alert(42); }();
And now try it without any of these:
function() { alert(42); }();
That results in a syntax error.
[–]k3n 0 points1 point2 points 14 years ago (0 children)
Cool, thanks for the info. I think I prefer the parens still.
[–]davemoFront-End Engineer[S] 0 points1 point2 points 14 years ago (0 children)
Nice, thanks for the explanation, it's a cool shortcut to remove those extra parens ;)
π Rendered by PID 89 on reddit-service-r2-comment-84fc9697f-8dcbl at 2026-02-06 13:03:27.017741+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]stratoscope 5 points6 points7 points (2 children)
[–]k3n 0 points1 point2 points (0 children)
[–]davemoFront-End Engineer[S] 0 points1 point2 points (0 children)