Javascript examples for String:charAt
Return the last character of a string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from w w w.j av a 2 s . c om*/ var str = "HELLO WORLD"; var res = str.charAt(str.length-1); document.getElementById("demo").innerHTML = res; } </script> </body> </html>