lastIndexOf() 예제
<button onclick="homzzang()">클릭</button> <p id="demo"></p> <script> function homzzang() { var str = "홈짱닷컴 Homzzang.com. Welcome to Homzzang.com"; var n = str.lastIndexOf("Homzzang"); document.getElementById("demo").innerHTML = n; // 30 } </script> 결과보기
<button onclick="homzzang()">클릭</button>
<p id="demo"></p>
<script>
function homzzang() {
var str = "홈짱닷컴 Homzzang.com. Welcome to Homzzang.com";
var n = str.lastIndexOf("Homzzang");
document.getElementById("demo").innerHTML = n; // 30
}
</script>
결과보기
※ Homzzang 문자열이 마지막으로 나타나는 위치 찾기.