InterviewSolution
Saved Bookmarks
| 1. |
What is the “spread” operator in ES6? |
|
Answer» The list of parameters is OBTAINED using the spread operator. Three dots (...) are used to represent it. The spread operator divides an iterable (such as an array or a string) into individual elements. It's mostly used in JavaScript to make shallow copies of JS. It improves the READABILITY of your code by making it more concise. The spread operator can be used to join two ARRAYS together or to concatenate them. let arr1 = [4, 5, 6]; let arr2 = [1, 2, 3, ...arr1, 7, 8, 9, 10]; console.log(arr2);Output: [ 1 2 3 4 5 6 7 8 9 10 ] |
|