1 string reversal

Ideas:

A traverse, determines the array into the

2 '' is divided into an array, and then reverse direction, then join to a string, the final determination

    <script>      
    function test(){
       var s1 = "abcdefg";
       var s2 = "gfedcba"; 
       alert(s1.split('').reverse().join(''));
       alert(s2 == s1.split('').reverse().join(''));
    }  
    </script>

 

 

Guess you like

Origin www.cnblogs.com/ltfxy/p/11947211.html