Junior JavaScript

What is the spread operator?

Used to expand arrays or objects into individual elements.

Example:

const arr = [1, 2, 3];

const newArr = [...arr, 4, 5]; // [1, 2, 3, 4, 5]

More from JavaScript Tutorial

All questions for this course