function reverseString(str) { str = str.split('').reverse().join('') return str; } reverseString("hello"); // olleh
expand:
Common string methods charAt (num) // Get the single character at the specified index position charCodeAt (num) // Get the Unicode value of the character at the specified index position (ascii is a subset) concat (str01,str02) // Concatenate two characters ~ indexOf ( "str" ) // take the index of the first occurrence of str lastIndexOf ( "str" ) // take the index of the last occurrence of str replace ( "oldStr" , "newStr" ) // find oldStr and replace it with newStr slice ( start , end ) // The object can be a string or an array, remember that the range does not include end substr (start, length) // length characters are taken from the index start, length cannot be less than 0, otherwise an empty string is returned Common array methods pop () // delete last item shift () // delete first item push () // add to last unshift () // add to first indexOf () // array element index slice () // intercept (slice ) array to get the intercepted array concat () // array merge reverse () // array flip