Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- What is an Array? 4:35
- Create an Array 2 objectives
- Access Elements in an Array 3:04
- Access Array Elements by Index 2 objectives
- Review Array Basics 5 questions
- Add Elements to an Array 4:10
- Add Elements to an Array 2 objectives
- Remove Elements From an Array 4:17
- Remove Elements From an Array 2 objectives
- Copy and Combine Arrays with the Spread Operator 7:18
- Review Adding, Removing, and Copying Array Elements 6 questions

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
Learn the basics of the spread operator (...
), a special syntax JavaScript provides to build, combine, and manipulate arrays quickly and more seamlessly.
Resources
Making a copy of an array with the spread operator
One of the main benefits of copying an array is that you preserve the values of the original array. For example, the original mathStudents
and scienceStudents
arrays remain unchanged (won't be mutated) if you decide to push or pop elements in and out of the copies of those arrays.
const mathStudents = [
'Marty',
'Jennifer',
'Lorraine',
'Goldie'
];
const scienceStudents = [
'Emmett',
'Clara',
'Needles',
'Strickland'
];
const mathStudentsCopy = [...mathStudents];
const scienceStudentsCopy = [...scienceStudents];
// This affects the copied arrays only
// The original arrays remain unchanged
mathStudentsCopy.pop();
scienceStudentsCopy.push('Marvin');
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Daniel Benisti
Front End Web Development Techdegree Graduate 22,224 Points1 Answer
-
trottly
5,394 Points2 Answers
-
Sonia Nitu
Front End Web Development Techdegree Student 10,852 Points1 Answer
-
Jelena Feliciano
Full Stack JavaScript Techdegree Student 12,729 Points2 Answers
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up