点击运行
const arr = ['one two', 'three four']; const result = arr.reduce
( (acc, curr) => acc.concat(splitOnSpace(curr)), [], ); console.log(result); // ['one', 'two', 'three', 'four'] function splitOnSpace(str: string) { return str.split(' '); }
运行结果 :
正在执行...