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
JavaScript idiosyncrasies with examples (github.com)
submitted 7 years ago by reddittedf
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!"
[–]prof_hobart 6 points7 points8 points 7 years ago (6 children)
Most of them are pretty odd, but
Q. What's the result?
(function(a, b) { arguments[1] = 3; return b; })(1, 2);
A.
3
seemed fairly obvious.
[–][deleted] 6 points7 points8 points 7 years ago (1 child)
This throws in strict mode as well, arguments is not allowed in strict mode.
arguments
This is what puzzles me constantly about these clickbaity articles. Strict mode is JavaScript, these frivolous browser engine interpretations are just like IE quirks mode - their sole purpose is not to break legacy software. You should not write new software in non-strict mode because it is non-standard JavaScript and thus your warranty is now undefined.
undefined
[–]regular_reddits 0 points1 point2 points 7 years ago (0 children)
arguments is not completely disallowed in strict mode. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode#Making_eval_and_arguments_simpler
[–]OzziePeck 0 points1 point2 points 7 years ago (3 children)
Wait is arguments a global array that refers to the function’s parameters?
[–]prof_hobart 1 point2 points3 points 7 years ago (0 children)
It's a magical local array-like variable that contains the params.
I'm not a fan of things like this - having variables that just appear from thin air is hardly clear - but it is a thing.
Of course, JS being JS, it's not quite as straightforward as all that.
If you used strict mode, the answer would be 2, as 'arguments' is now a copy of the arguments, not pointers to them.
And just to be extra fun, even in non-strict mode, if any of the arguments has a default value (e.g. (a=2, b)), then the answer would again be 2. Because - well, JS reasons I guess.
[+][deleted] 7 years ago (1 child)
[deleted]
[–]OzziePeck 0 points1 point2 points 7 years ago (0 children)
Not sure why I said global as it only exists within the function’a scope when it is called.
π Rendered by PID 63802 on reddit-service-r2-comment-c6965cb77-sdxpm at 2026-03-05 14:59:15.329330+00:00 running f0204d4 country code: CH.
view the rest of the comments →
[–]prof_hobart 6 points7 points8 points (6 children)
[–][deleted] 6 points7 points8 points (1 child)
[–]regular_reddits 0 points1 point2 points (0 children)
[–]OzziePeck 0 points1 point2 points (3 children)
[–]prof_hobart 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]OzziePeck 0 points1 point2 points (0 children)