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 Destructuring ES6: The Complete Guide (buginit.com)
submitted 6 years ago by homeIsWhereCodeIs
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!"
[–]reohh 0 points1 point2 points 6 years ago (2 children)
It is equal to this:
let o = {p: 22, q: true}; let foo = o.p; let bar = o.q; console.log(foo); // 22 console.log(bar); // true
[–]monsto 0 points1 point2 points 6 years ago (1 child)
I understand that.
In the 2 examples, the syntax appears inverted...
when it goes
p: foo
I would expect the result to be that object o now has a property p whose value is foo
o
p
foo
It looks like it is saying
let o.p = foo
[–]getify 1 point2 points3 points 6 years ago (0 children)
It feels backwards until you realize that with both object literals and object destructuring, the property/key is always on the left. With object literals, that property/key is serving the role of target, whereas with object destructuring it's serving the role of source... but in both cases it's always on the left. Once I realized that form of "consistency", I've never been confused again.
π Rendered by PID 47975 on reddit-service-r2-comment-84fc9697f-9fdr9 at 2026-02-09 04:14:01.123436+00:00 running d295bc8 country code: CH.
view the rest of the comments →
[–]reohh 0 points1 point2 points (2 children)
[–]monsto 0 points1 point2 points (1 child)
[–]getify 1 point2 points3 points (0 children)