전체 페이지뷰

2013년 11월 15일 금요일

javascript array delete by value with comma

oh my god!

I almost spend one hour to searching method that remove element with comma in javascript Array !

I would have had no sense of javascript.

I first try to remove the element the value

It was very simple source but comma was not deleted.
Array.prototype.remove=function(v){
    delete this[this.indexOf(v)];
};

I finally found the delete comma and element method .

Array.prototype.remByVal = function(val) {
   for (var i = 0; i < this.length; i++) {
     if (this[i] === val) {
 this.splice(i, 1);
 i--;
     }
   }
   return this;
};










댓글 없음:

댓글 쓰기