Posted By

djmicahelb on 04/11/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wirenaught


Javascript .clean Array


 / Published in: JavaScript
 

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

Normally "" - to remove blank data from the Array

  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  

You need to login to post a comment.