Javascript Tutorial - Remove an Element from an Array

Publié le: 20 juillet 2021
sur la chaîne: 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.


Sur cette page du site, vous pouvez voir la vidéo en ligne Javascript Tutorial - Remove an Element from an Array durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur B-dev 20 juillet 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 147 fois et il a aimé 8 téléspectateurs. Bon visionnage!