JavaScript反转字符串

方法一

var str = "abcde"
str = str.split("").reverse().join("")

方法二

var str = "abcde"
var len = str.length;

var arr = str.split("")

for (var i = 0; i < parseInt(len / 2); i++) {
  var temp = arr[i]
  arr[i] = arr[len - i - 1]
  arr[len - i - 1] = temp
}
str = arr.join("")