Spread operator allows iterables( arrays / objects / strings ) to be expanded into single arguments/elements. Let’s take an example to see this behavior:
1 2 3 4 5 6 7 | function calculateSum(x, y, z) { return x + y + z; } const numbers = [1, 2, 3]; console.log(calculateSum(...numbers)); // 6 |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.