Javascript первые символы строки. Метод replace. string.replace(s, old, new[, maxreplace]). строки s[::-1].