Extract the characters from position 3 to 8: - Javascript String

Javascript examples for String:slice

Description

Extract the characters from position 3 to 8:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*  www.j  a va2 s. co m*/
    var str = "Hello world!";
    var res = str.slice(3, 8);
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>

Related Tutorials