0 day streak
javascript / beginner
Snippet

Array Destructuring for Variables

Array destructuring allows you to unpack values from arrays into distinct variables based on their position.

snippet.js
javascript
1
2
3
4
5
function Tools() {
const tech = ['React', 'Vite'];
const [primary] = tech;
return <p>Primary: {primary}</p>;
}
react
Breakdown
1
const [primary] = tech;
Extracts the first element of the 'tech' array into the variable 'primary'.