Returns the n rightmost characters in a string
Notes:
Simple examples:
"Lorem ipsum".right(0); // result: "" "Lorem ipsum".right(1); // result: "m" "Lorem ipsum".right(5); // result: "ipsum" "Lorem ipsum".right(15); // result: "Lorem ipsum"
The last example shows that if the source string is shorter than the number given, this will just return the entire source string, but no more.
That is, unless you also specify a padding character:
"Lorem ipsum".right(15, "-"); // result: "----Lorem ipsum"
A good use-case for the padding option is the formatting of hexadecimal numbers:
(12).toString(16).right(4, "0"); // result: "000c" (= decimal 12)