JavaScript Destructuring, Spread Operator, Rest Parameters, Nullish Coalescing Operator, and Logical Assignment Operators
JavaScript offers several powerful syntactic features for manipulating data and simplifying code: destructuring, spread operator, rest parameters, nullish coalescing operator, and logical assignment operators. These features enhance the language's expressiveness and make it easier to write concise and readable code. Destructuring Destructuring allows you to extract properties from objects or arrays into individual variables. Object Destructuring: const person = { name: "John", age: 30 }; // Extract name and age const { name, age } = person; console.log(name); // John console.log(age); // 30 Array Destructuring: const colors = ["red", "green", "blue"]; // Extract the first two colors const [first, second] = colors; console.log(first); // red console.log(second); // green Spread Operator The spread operator (...) allows you to expand an array or object into individual elements within a new array or object. Array ...