I have a question about array destructuring. I have a data shaped like this :
const sample = [['1', '2,', '3'], ['4', '5,', '6']]
And I was wondering if there was a "one liner" way to get to the first element of the first array, something a little bit like this :
const [ first[0] ] = sample
Right now I'm doing something like this but I find it less "elegant" (I know it's not a problem at all, just trying to expand my knowledge =)
const [ tmp ] = sample
const first = tmp[0]
Thank you in advance for your help !
let [[a], [b]] = sample;
console.log(a, b); // "1" "4"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With