Method One: Using the Charat method under the String object
The CharAt () method returns the character at the specified position.
Str.charat (str.length–1)
Note that JavaScript does not have a character data type that is different from the string type, so the returned character is a string of length 1
Method Two: Using the Substr method under the String object
The substr () method extracts a specified number of characters from the start subscript in a string.
Str.substr (str.length-1,1)
Important: ECMAscript does not standardize the method and therefore opposes its use.
Important: In IE 4, the value of the parameter start is invalid. In this BUG, start specifies the position of the No. 0 character. (www.jb51.net) in a later release, this BUG has been fixed.
Method Three: Using the Split method under the String object
The split () method is used to split a string into an array of strings.
var str = "123456″;SPSTR = Str.split (" "); spstr[spstr.length-1];
Method Four: Regular fix
<script type= "Text/javascript" >//<! [Cdata[var s = "nasofj;n234n41;v"; Alert ("String:" +s+ "nn" + "LaStone:" +s.replace (/^ (. *[n]) *. * (. | N) $/g, "$");//]]></script>
JS Get string Last method