Используйте
подстрока
функция
Возвращает подмножество строки между
один индекс и другой, или через
конец строки.
substring(indexA, [indexB]);
indexA
An integer between 0 and one less than the length of the string.
IndexB
(необязательно) Целое число от 0 до длины строки.
подстрока извлекает символы из indexA до, но не включая indexB. В частности:
* If indexA equals indexB, substring returns an empty string.
* If indexB is omitted, substring extracts characters to the end
of the string.
* If either argument is less than 0 or is NaN, it is treated as if
it were 0.
* If either argument is greater than stringName.length, it is treated as
if it were stringName.length.
Если indexA больше, чем indexB, то эффект подстроки будет таким, как если бы два аргумента были заменены; например, str.substring (1, 0) == str.substring (0, 1).