JS Coding Questions Logo
JS Coding Questions
#189💼 Interview💻 Code

What is a spread operator

Advertisement

728x90

Spread operator allows iterables( arrays / objects / strings ) to be expanded into single arguments/elements. Let's take an example to see this behavior,

javascript
1function calculateSum(x, y, z) {
2  return x + y + z;
3  }
4
5const numbers = [1, 2, 3];
6
7console.log(calculateSum(...numbers)); // 6

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 18

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
189of476