JavaScript for Beginners #56 The splice() Array Method

Опубликовано: 21 Март 2021
на канале: GreeneMath.com
290
14

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


Смотрите видео JavaScript for Beginners #56 The splice() Array Method онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь GreeneMath.com 21 Март 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 290 раз и оно понравилось 14 людям.