嗨,我需要转换这个:
// Convert [[1],[2],[3],[4],["a","b","c"],["d","e","f"]]
对此:
[1,2,3,4,"a","b","c","d","e","f"]
在 MS Office 脚本中。我无法使用
我尝试过使用 array.flat() 之类的东西,但它在 Office Script API 中不存在。
感谢任何帮助,我是 Office 脚本新手!
你可以试试
Array::reduce()
:
const result = [[1],[2],[3],[4],["a","b","c"],["d","e","f"]].reduce((r, item) => (item.forEach(x => r.push(x)), r), []);
console.log(...result);