Edit This Code:
See Result »
<!DOCTYPE html> <html> <body> <p>Click the button to extract characters from the string.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var str = "Hello world!"; var res = str.substring(2); document.getElementById("demo").innerHTML = res; } </script> </body> </html>
Result: