Javascript examples for String:substr
Extract only the last character:substr(11, 1)
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww . j a v a 2 s.c o m var str = "Hello world!"; var res = str.substr(11, 1); document.getElementById("demo").innerHTML = res; } </script> </body> </html>