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

What is the output of below spread operator array

Advertisement

728x90
javascript
1[..."John Resig"];

The output of the array is ['J', 'o', 'h', 'n', ' ', 'R', 'e', 's', 'i', 'g']

Explanation: The string is an iterable type and the spread operator within an array maps every character of an iterable to one element. Hence, each character of a string becomes an element within an Array.

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 68

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
325of476