Here, we will learn about the splice() array method in JavaScript. This can be used to delete items, add items into any array at a certain position, or replace items in an array with new ones.
Also, I forgot to state that you can add in an item without deleting something by using a delete count of 0. Here's an example:
const myArray = [1, 2, 4];
myArray.splice(2, 0, 3);
// [1, 2, 3, 4];
Last Example:
const currentFoods = ["Chicken", "Corn", "Rice", "Steak", "Potatoes", "Pasta", "Tacos", "Hamburger"];
const dislikedFoods = ["Pasta", "Corn"];
0:00 MDN splice() method
0:36 Creating an array with bathroom items
1:21 Removing an element from an arry with the splice() method
3:23 Adding/Replacing elements into/in an array with splice() method
4:34 Working with the return value (deleted items)
5:16 Working with a dynamic delete count using array.length
6:23 Using a negative index
7:48 Combining the indexOf() method with the splice() method
JavaScript Playlist:
• JavaScript for Beginners
MDN splice() Method:
https://developer.mozilla.org/en-US/d...
NodeJS:
nodejs.org
VS Code:
code.visualstudio.com
Watch video JavaScript for Beginners #56 The splice() Array Method online without registration, duration hours minute second in high quality. This video was added by user GreeneMath.com 21 March 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 290 once and liked it 14 people.