let str="sff";
let arr=[...str]
console.log(arr) //第一种方式 ["s", "f", "f"]
console.log(Array.from(str)) //第二种方式 ["s", "f", "f"]
本文介绍了在JavaScript中将字符串转换为数组的两种常见方法:使用扩展运算符和Array.from()函数。通过示例演示了如何操作,展示了这两种方式的具体用法及输出结果。
let str="sff";
let arr=[...str]
console.log(arr) //第一种方式 ["s", "f", "f"]
console.log(Array.from(str)) //第二种方式 ["s", "f", "f"]

被折叠的 条评论
为什么被折叠?