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
Post a Comment