루프와 스플릿을 사용하여 요소를 교체하고 삭제하는 것은 매우 간단하지만 실용적이며 특히 초보자에게 적합합니다.
<! docType> <Html> <Head> <메타 http-equiv = "content-type"content = "text/html; charset = utf-8"/> <title> 루프와 스플릿을 사용하여 요소를 교체하고 삭제합니다. 배열 ( "ab", "aa", "bc", "ab", "ss", "ab", "ss", "ab", "ss", "dd", "ab", "aa", "aa", "aa", "aa"); while (arr.indexof ( "ab")! = -1) {console.log ( "1"+arr); arr.splice (arr.indexof ( "ab"), 1, "**"); } console.log (ARR); while (arr.indexof ( "**")! = -1) {console.log (arr); arr.splice (arr.indexof ( "**"), 1); } console.log (ARR); </script> </head> <body> </body> </html>IE8은 Indexof 및 Splice를 지원하지 않습니다