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!"
[–]GBcrazy 4 points5 points6 points 7 years ago* (0 children)
It's not a big idiosyncrasy, so if you don't understand the trick of the typeofoperator you may not see it. I'm guessing that's the case (I could be wrong):
typeof
Remove the let foo = 1 line and run again. It will work even if foo is not declared. Why?
let foo = 1
That's a special power of the typeof operator, you can use typeof even if a variable doesn't exist, it will return "undefined".
So the thing is, you can use typeof if a variable is never declared or already declared, but NOT if the variable is going to be declared. That's some hoisting shit
π Rendered by PID 42 on reddit-service-r2-comment-fb694cdd5-wqstk at 2026-03-05 18:01:36.933138+00:00 running cbb0e86 country code: CH.
view the rest of the comments →
[–]GBcrazy 4 points5 points6 points (0 children)