자바스크립트 배열 추가, 삭제 예제 javascript array add item, remove
출처 : 본인
출처2 : http://ejohn.org/blog/javascript-array-remove/
출처3 : https://fimtrus.tistory.com/entry/Javacript-Array-remove-Index-%EB%B0%B0%EC%97%B4-%EC%82%AD%EC%A0%9C
//배열 요소 추가
function GetCCls_Result(data) {
var xmlData = $.parseXML(data);
var Table = $("Table", xmlData);
Table.each(function () {
var ClsGrpCD = $("ClsGrpCD", $(this)).text();
var ClsCD = $("ClsCD", $(this)).text();
var Name = $("Name", $(this)).text();
clsCD.push({
ClsGrpCD: ClsGrpCD,
ClsCD: ClsCD,
Name: Name
});
});
}
//배열 요소 사용
function GetClsCD_Client(ClsGrpCD) {
$("#selClsCD option:gt(0)").remove();
for (var i = 0; i < clsCD.length ; i++) {
if (clsCD[i].ClsGrpCD == ClsGrpCD) {
$("#selClsCD").append("<option value=" + clsCD[i].ClsCD + ">" + clsCD[i].Name + "</option>");
}
}
}
//배열 요소 삭제
Array.prototype.remove = function (from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};