0.4.5: Destructuring and Spread Operator
Learning Objectives
Introduction
Destructuring Assignment
Example: Array destructuring syntax
const row = ["X", "O", "X"];
const [left, center] = row;
console.log(left); // Output 'X'
console.log(center); // Output 'O'Example: Object destructuring syntax
Example: Return Multiple Values from Functions
Example: Import Multiple Named Exports
Spread Operator
Example: Make Shallow Copy of Array
Example: Concatenate Arrays
Example: Concatenate Objects
Last updated