颠倒字符串需要用到的三大基友 .reverse() .split('') .join('')

          var string = "Welcome to this China!";
                console.log(string)
                let a = string.split('') // 分隔成一个个的字符数组
                // ["W", "e", "l", "c", "o", "m", "e", " ", "t", "o", " ", "t", "h", "i", "s", " ", "C", "h", "i", "n", "a", "!"]
                console.log(a)
                let b = a.reverse() // 于颠倒数组中元素的顺序
                // ["!", "a", "n", "i", "h", "C", " ", "s", "i", "h", "t", " ", "o", "t", " ", "e", "m", "o", "c", "l", "e", "W"]
                console.log(b)
                let c = b.join('') // 把数组中的所有元素放入一个字符串
                // !anihC siht ot emocleW
                console.log(c)    

原文地址:https://www.cnblogs.com/time1997/p/14073557.html