JavaScript for Beginners #54 Destructuring Assignment Arrays

preview_player
Показать описание
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables. Here we will focus on arrays.

0:00 What is destructuring assignment in JavaScript
0:33 Creating an array of colors
1:13 Older method to store the elements of an array in variables
2:27 Using the destructuring assignment syntax
3:52 Using default values
5:00 Skipping over elements
6:53 Assigning the rest of an array to a variable
7:30 Working with a nested array
9:29 Swapping variable values
12:07 Working with return values from a function

Last Example:
const myStore = {
groceries: [["Milk", 5], ["Bread", 1], ["Butter", 3], ["Cereal", 2], ["Corn", 3], ["Rice", 2], ["Steak", 10]],
generalItems: [["Cleaner", 3], ["Towels", 6], ["Mop", 10], ["Pans", 12], ["Shirts", 4]],
purchaseItems: function (groceryIndex, generalIndex) {
}
}

JavaScript Playlist:

MDN Destructuring Assignment:

NodeJS:

VS Code:
Рекомендации по теме
Комментарии
Автор

Good job sir, your explanation is awesome😊

pallavids