Try some validation on the index before splice.
function deleteKodePelayanan(index){
index = parseInt(index,10);
if (isNaN(index)) {
// index is not a number
return;
} else if (!(index in kode_pelayanan)) {
// index is a number but the value isn't set
return;
}
kode_pelayanan.splice(index, 1);
}