Created
August 10, 2023 03:43
-
-
Save sakshstore/43aaff85aca53709b87fd08249223f3d to your computer and use it in GitHub Desktop.
Array destructuring allows you to extract individual elements from an array and assign them to separate variables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Longhand | |
const numbers = [1, 2, 3]; | |
const firstNumber = numbers[0]; | |
const secondNumber = numbers[1]; | |
// Shorthand | |
const numbers = [1, 2, 3]; | |
const [firstNumber, secondNumber] = numbers; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment