📜  使用 reduce 将数组减少为单个字符串 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:18.998000             🧑  作者: Mango

代码示例1
var authorString = authors.reduce(function(prevVal,currVal,idx){
    return idx == 0 ? currVal : prevVal + ', ' + currVal;
}, '')
console.log(authorString);