Javascript .clean Array


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

use this script to step through an Array and strip out the specified value...

Normally "" - to remove blank data from the Array


Copy this code and paste it in your HTML
  1. Array.prototype.clean = function(deleteValue) {
  2. for (var i = 0; i < this.length; i++) {
  3. if (this[i] == deleteValue) {
  4. this.splice(i, 1);
  5. i--;
  6. }
  7. }
  8. return this;
  9. };
  10.  
  11. //usage
  12.  
  13. youArray = yourArray.clean("");

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.