나는 js 배열을 가지고 있고 그것을지도로 사용한다. 이것은 동적이다 (이 예에서는 그렇지 않다). 그래서 얼마나 많은 요소를 가질 지 모르겠다.
발견 된 모든 요소를 제거하고 싶습니다.
이것은 루프 후 배열의 최종보기입니다.
movmet_sequence_history:[]
movmet_sequence_history["0"] = "A"
movmet_sequence_history["1"] = "B"
movmet_sequence_history["2"] = "C"
movmet_sequence_history["3"] = "D"
....
....
....
....
movmet_sequence_history["20"] = "Z"
if(movmet_sequence_history["2"] == "C")
{
//HERE I WANT TO REMOVE THE ELEMENTS "2" ,"1" ,"0"
//Only the movmet_sequence_history["3"] = "D" will remain
}
업데이트 : 나는 배열이 동적이라고 말했듯이 올바른 요소를 수동으로 삭제하지 않으며 발견 된 요소에 얼마나 많은 요소가 있는지 모릅니다.
정의되지 않은 상태로 만들 수 있습니다.
movmet_sequence_history:[]
movmet_sequence_history["0"] = "A"
movmet_sequence_history["1"] = "B"
movmet_sequence_history["2"] = "C"
movmet_sequence_history["3"] = "D"
if(movmet_sequence_history["2"] == "C")
{
movmet_sequence_history["0"] = undefined;
movmet_sequence_history["1"] = undefined;
movmet_sequence_history["2"] = undefined;
//Only the movmet_sequence_history["3"] = "D" will remain
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다