js数组用逗号形式隔开

遍历数组:

复制代码
let fh = ',';
let tagArr = [
{id:1,tageName:"张三",age:10},
{id:2,tageName:"李斯",age:20},
{id:3,tageName:"李丽",age:30}
]
let strTag = tagArr.map(function(obj,index){
                      if(obj!=null){
                        if(obj.tagName!=null){
                          return obj.tagName;
                        }else{
                          fh = ''
                        }
                      }else{
                        fh = ''
                      }
                  }).join(fh);
console.log(strTage,'>>>>');//结果:strTage = 张三,李斯,李丽
复制代码

 

posted on   婧星  阅读(10234)  评论(0编辑  收藏  举报

努力加载评论中...

导航

点击右上角即可分享
微信分享提示