Javascript remove item from array


/ Published in: JavaScript
Save to your folder(s)

Simply pass in array name and the value of the item you want to remove


Copy this code and paste it in your HTML
  1. function removeByElement(arrayName,arrayElement)
  2. {
  3. for(var i=0; i<arrayName.length;i++ )
  4. {
  5. if(arrayName[i]==arrayElement)
  6. arrayName.splice(i,1);
  7. }
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.