Javascript Tutorial - Remove an Element from an Array

Published: 20 July 2021
on channel: 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.


On this page of the site you can watch the video online Javascript Tutorial - Remove an Element from an Array with a duration of hours minute second in good quality, which was uploaded by the user B-dev 20 July 2021, share the link with friends and acquaintances, this video has already been watched 147 times on youtube and it was liked by 8 viewers. Enjoy your viewing!