javascript - how to get the last character of a string? -


how last character of string:

"linto.yahoo.com." 

the last character of string "."

how can find this?

an elegant , short alternative, string.prototype.slice method.

just by:

str.slice(-1); 

a negative start index slices string length+index, length, being index -1, last character extracted:

"abc".slice(-1); // "c"; 

Comments

Popular posts from this blog

silverlight - Applying a style to ItemContainerStyle in C# -

c# - NullReferenceException in MySqlClient.NativeDriver -

php - Updating recent updates - Problem in procedure - Any other approach? -