MoreLesson 283Free preview
JS Spread Operator
This lesson is part of How To · All levels
Summary
The spread operator is a three-point (...) syntax in JavaScript that opens the contents of an array or object into separate parts. This operator is very useful for copying data, combining multiple arrays, and creating new objects without changing the original object. Because the copy is shallow, you need to be careful if it contains objects or clusters.
Key points
- Written with three dots (...) in front of an array, object, or value that can be iterated
- Can be used to make a superficial copy of arrays and objects
- Facilitate the integration of arrays or the addition of new properties to an object
- In function naming, the spread converts the array into a list of arguments
- The copy is shallow, so the reference to the object in it is the same.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.