From the course: Computer Science Principles Lab: JavaScript
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Changing arrays - JavaScript Tutorial
From the course: Computer Science Principles Lab: JavaScript
Changing arrays
- [Instructor] After you create an array, there are many ways you can change the values and manipulate it using JavaScript. There are three basic functions that are part of any array that you can use to add, change, and remove elements within an array. First, we have an array already created with four elements. If we want to add an element, we can use the push() function. Push() is a function that is part of every array that adds an item to the end of the array. To use it, start with the array name, then add a period, and then add a call to the push() function. Inside of the push() function call, add in the item you want to add to the array. You can add multiple items by separating each with a comma, then send the array to the console to display it. Save and open the webpage in your browser. You'll see that the second array is now displayed and has an additional item inside of it, with the new element that you have pushed onto the end. There is one thing I wanted to point out that…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Capture input from the user9m 17s
-
(Locked)
Manage different variable types6m 43s
-
(Locked)
Create conditional tests12m 16s
-
(Locked)
Build compound conditional tests8m 42s
-
(Locked)
Use while loops4m 13s
-
(Locked)
Use for loops7m 35s
-
Create arrays to store groups of values3m 36s
-
(Locked)
Use loops with arrays3m 26s
-
(Locked)
Changing arrays3m
-
(Locked)
-