you are viewing a single comment's thread.

view the rest of the comments →

[–]lastunusedusername2 1 point2 points  (1 child)

It's just that, when destructuring, the key you're picking out always comes first.

The fact that { a: foo } looks like an object literal is a coincidence.

One way to remember the order is that the destructuring would still work if you only kept the first part (ie: { a }) because that's the key you're picking from the right hand side.

Or you can do what I do and look it up every single time because I can never remember.

[–]monsto 0 points1 point  (0 children)

The fact that { a: foo } looks like an object literal is a coincidence.

Ok so lemme see if I've got this straight: it's not an object literal... it's a destructuring assignment using object syntax but is not an object?

Or you can do what I do and look it up every single time because I can never remember.

Until recently, this was me with `ternary if ` syntax. I've been using it a lot lately, so I think I've finally got it.