If "start" is greater than "end", it will swap the two arguments: - Javascript String

Javascript examples for String:substring

Description

If "start" is greater than "end", it will swap the two arguments:

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  . j ava2s  .c om
    var str = "Hello world!";
    var res = str.substring(4, 1);
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>

Related Tutorials