add the old snippet md files

This commit is contained in:
Travis Shears 2025-06-05 16:20:57 +02:00
parent fc0dd204c7
commit bcf8313a4b
110 changed files with 3048 additions and 0 deletions

View file

@ -0,0 +1,27 @@
---
title: "destructuring an array in javascript"
date: 2021-11-29T09:22:30+01:00
draft: false
seo_description: "Turns out you don't need blank variables at all, simply using commas is enough"
snippet_types:
- js
---
How I use to destructure Arrays:
```js
const nums = [1,2,3];
const [a, _, c];
(a === 1) // true
(c === 3) // true
```
Problem is this **_** is not needed and will cause problems with some ESLint
setups. For example they might not allow unused variables. Turnes out you
can just leave that spot blank!
```js
const nums = [1,2,3];
const [a, , c];
(a === 1) // true
(c === 3) // true
```