Begin the extraction at position 2, and extract the rest of the string:substring(2) - Javascript String

Javascript examples for String:substring

Description

Begin the extraction at position 2, and extract the rest of the string:substring(2)

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

<script>
function myFunction() {//from w ww.ja  v a  2s.  c  o m
    var str = "Hello world!";
    var res = str.substring(2);
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>

Related Tutorials