JavaScript
자바스크립트 리스트에서 아이템 제거 (given value)
SaintHwang
2016. 4. 28. 10:45
Array.prototype.remove = function(value) {
this.splice( this.indexOf(value), 1);
return true;
};
a=[112, 234, 32545];
a.remove(234);
// [112, 32545];
a.remove(22);
// still [112, 32545];
a.remove(234);
// [112, 32545];
a.remove(22);
// still [112, 32545];
상단의 코드를 넣어 프로퍼티를 손봐준다.
그다음에 .remove ( 'item' ); 을 이용하여 제거한다.