数组字符串转数组格式, 使用 JSON.parse
// 元数据
let arrString = '["abc","123"]';
// 转换为数组
let array = JSON.parse(arrString);
console.log(array[0]); // abc
类似数组对象转数组, 使用 Array.from
let arrayLike = { length: 2, 0: 'a', 1: 'b' };
// 报错
for (let x of arrayLike) {
console.log(x);
}
// 正确
for (let x of Array.from(arrayLike)) {
console.log(x);
}