0

我想将一个 JavaScript 字符串分成一个数组,这样:

"emad566" 

变成这样:

["e","m","a","d","5","6","6"]

我也想把它反转成这样:

["6","6","5","d","a","m","e"]
4

2 回答 2

5

使用.split().reverse()

var arr =  mystring.split("").reverse();
于 2012-10-08T13:23:08.157 回答
2
var str = "emad566"
arr = str.split('').reverse()

然后 arr 是["6", "6", "5", "d", "a", "m", "e"]

于 2012-10-08T13:25:12.210 回答