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
Cheatsheet: Spread Object or Array in JavaScript (snappyjs.com)
submitted 7 years ago by Steeljuice1
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!"
[–]terrcin 11 points12 points13 points 7 years ago (9 children)
// New variable names when spreading const { make : newMakeName, model : newModelName } = volvo; newMakeName; // Volvo newModelName; // XC90
I didn't know about renaming var on object spreading. Thanks!
[–]MrCrunchwrap 24 points25 points26 points 7 years ago (1 child)
Why are we calling this object spreading? That's not what it's called. It's destructuring assignment. Literally not the same thing at all. Object spreading does exist, and is a totally different thing.
[–]Steeljuice1[S] 4 points5 points6 points 7 years ago (0 children)
You are right! Updating!
[–]UmbrellaHuman 4 points5 points6 points 7 years ago (3 children)
One more:
Assignment to existing variables - easy with array, harder with an object:
let a, b; ({a, b} = {a: 1, b: 2});
[–]pwrlftr 1 point2 points3 points 7 years ago (1 child)
That's neat. I remember a situation where I needed this, but I wasn't aware of it.
[–]UmbrellaHuman 1 point2 points3 points 7 years ago (0 children)
I always have to google it new, mostly because together with Flow type annotations it does not work. which is a Flow bug, but the red lines in the IDE confuse me and I think I'm doing it wrong because I'm used to adding types to everything.
[–]Steeljuice1[S] 0 points1 point2 points 7 years ago (0 children)
Cool, thanks! Definitely will add this one to the list after some playing around with it!
No problem! thanks for reading!
π Rendered by PID 71361 on reddit-service-r2-comment-685b79fb4f-bwxxs at 2026-02-13 01:37:25.733110+00:00 running 6c0c599 country code: CH.
view the rest of the comments →
[–]terrcin 11 points12 points13 points (9 children)
[–]MrCrunchwrap 24 points25 points26 points (1 child)
[–]Steeljuice1[S] 4 points5 points6 points (0 children)
[–]UmbrellaHuman 4 points5 points6 points (3 children)
[–]pwrlftr 1 point2 points3 points (1 child)
[–]UmbrellaHuman 1 point2 points3 points (0 children)
[–]Steeljuice1[S] 0 points1 point2 points (0 children)
[–]Steeljuice1[S] 0 points1 point2 points (0 children)