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

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -