Follow

TIL to destructure a parent and its child at the same time in JS

const {
parent,
parent: { child },
} = something

There are real reasons that syntax isn't intuitive. 10,000 times I wanted to do this...

· · Web · 1 · 0 · 0

@kevinflo I'm always nervous to destructure like this in case 'parent' is null

Sign in to participate in the conversation
Tinyfed

A general purpose Mastodon instance for myself, friends, family, and whoever happened to join early. Now requires approval to join