Menu
LogoLingCourseTAResearch
Programming
  • Container
  • Go
  • Python
  • JavaScript
  • Java
  • C++
  • Database
LinuxPhilosophy下厨房Blog
GitHub
LogoLing
  • Course
  • TA
  • Research
  • Programming
    • Container
    • Go
    • Python
    • JavaScript
    • Java
    • C++
    • Database
  • Linux
  • Philosophy
  • 下厨房
  • Blog
  • GitHub

Iterate and delete element from array

July 30, 2018 · 1 min read

Array.prototype.splice()

The splice() method changes the contents of an array by removing existing elements and/or adding new elements.

let i = arr.length;
while (i--) {
if (arr[i] == something) {
arr.splice(i, 1);
}
}

Looping through array and removing items, without breaking for loop

Edit this page
Previous Post
« Link Namecheap Domain to GitHub Pages
Next Post
Update nested object in Vue.js »
Copyright © 2024 Ling. Built with Docusaurus.