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