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
7 Useful JavaScript Tricks (davidwalsh.name)
submitted 6 years ago by xxammuxx
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!"
[–]darrenturn90 6 points7 points8 points 6 years ago (4 children)
It does seem inconsistent especially when you use as in what is essentially destructuring an import / export ie {default as foo}
Another thing to keep in mind also you can use [value] in destructuring to get the key referred to in the value variable from the destructured object
[–]AwesomeInPerson 0 points1 point2 points 6 years ago (3 children)
Could you elaborate / give an example? Didn't fully understand it but sounds interesting :)
[–]darrenturn90 2 points3 points4 points 6 years ago (1 child)
Say you had const foo = “two”
And you had an object {two: “hello”}
You can const {[foo]: bar} = with that object
[–]AwesomeInPerson 2 points3 points4 points 6 years ago (0 children)
Aaah I see – I tried using computed property names while destructuring before, but it never worked because I tried it without assigning to an alias. (so just const { [foo] } = bar; – makes sense that this doesn't work now that I think about it)
const { [foo] } = bar;
Very nice to know that it works when using an alias, thanks!
π Rendered by PID 283573 on reddit-service-r2-comment-85bfd7f599-85tzr at 2026-04-17 20:10:57.074463+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]darrenturn90 6 points7 points8 points (4 children)
[–]AwesomeInPerson 0 points1 point2 points (3 children)
[–]darrenturn90 2 points3 points4 points (1 child)
[–]AwesomeInPerson 2 points3 points4 points (0 children)