1

1、split()

var arrString = 'abcdaabc';

var s = arrString.split("")
console.log(s)
// ["a", "b", "c", "d", "a", "a", "b", "c"]

2、[].slice.call() 或 Array.prototype.slice.call()

var s = [].slice.call(arrString)
//["a", "b", "c", "d", "a", "a", "b", "c"]

3、 Object.values()

var arrString = 'abcdaabc';
var s = Object.values(arrString)
console.log(s)
// ["a", "b", "c", "d", "a", "a", "b", "c"]

4、Array.from()
如果字符串中有表情等特殊字符时就要用到Array.from

var arrString = 'abcdaabc😂';

var s = Array.from(arrString)
console.log(s)

image.png


breathfish
43 声望2 粉丝