Javascript Tutorial - Remove an Element from an Array

Опубликовано: 20 Июль 2021
на канале: B-dev
147
8

Please Like and Subscribe for more valuable content.

In Javascript, using "indexOf" and "splice" allows you to delete a specific element from an array.

The environment used in this video is jsfiddle.net.
The code is as follows:

const arr = ["Tom", "has", "dirty", "socks"];
var index = arr.indexOf("dirty"); // index = 2
arr.splice(index, 1);
console.log(arr);

---

More JS tips will follow in the coming days and weeks. Stay tuned.


На этой странице сайта вы можете посмотреть видео онлайн Javascript Tutorial - Remove an Element from an Array длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь B-dev 20 Июль 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 147 раз и оно понравилось 8 зрителям. Приятного просмотра!