Javascript examples for String:substring
If "start" is greater than "end", it will swap the two arguments:
<!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>