JavaScript for Beginners #56 The splice() Array Method

preview_player
Показать описание
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];
// [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)
6:23 Using a negative index
7:48 Combining the indexOf() method with the splice() method

JavaScript Playlist:

MDN splice() Method:

NodeJS:

VS Code:
Рекомендации по теме
Комментарии
Автор

amazing and clear, thankx!!!! great work!

mtycoder
join shbcf.ru