底层string工具类,持续更新中
1.翻转字符串 function reverseString ( str ) { return str . split ( "" ) . reverse ( ) . join ( "" ) ; } `` 2. 字符串中出现最多次数的字符 function findMaxDuplicateChar ( str ) { var cnt = { } , //用来记录所有的字符的出现频次 c = '' ; //用来记录最大频次的字符 for ( var i = 0 ; i < str . length ; i ++ ) { var ci = str [ i ] ; if ( ! cnt [ ci ] ) { cnt [ ci ] = 1 ; } else { cnt [ ci ] ++ ; } if ( c == '' || cnt [ ci ] > cnt [ c ] ) { c = ci ; } } console . log ( cnt ) return c ; } 3. 判断回文字符串 `` `javascript function palindrome ( str ) { var reg = /[\W\_]/g ; var str0 = str . toLowerCase ( ) . replace ( reg , "" ) ; var str1 = str0 . split (