js 字符串按字符分割为数组 和 数组合并

207 阅读1分钟

字符串按字符分割为数组

let str='代码不止掘金不停'
let strArray=[...str]

将数组插入到另一个数组指定下标

let str='代码不止掘金不停'
let array=['hello','word']
let strArray=[...str]
array.splice(1,0,...str)//结果array 变为 ['hello','代','码','不','止','掘','金','不','停','word']