js字符串到数组的划分

时间:2012-10-08 13:22:32

标签: javascript

我想将一个JavaScript字符串分成一个数组,所以:

"emad566" 

成为这个:

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

我也想反过来成为这个:

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

2 个答案:

答案 0 :(得分:5)

使用.split().reverse()

var arr =  mystring.split("").reverse();

答案 1 :(得分:2)

var str = "emad566"
arr = str.split('').reverse()

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