猿来是你三十而立,砥砺前行,不忘初心,勇闯猿类

js对象数组中的某属性值 拼接成字符串

var objs=[
    {id:1,name:'张三'},
    {id:2,name:'李四'},
    {id:3,name:'王五'},
    {id:4,name:'赵六'},
];

var idsStr = objs.map(function(obj,index){
    return obj.id;
}).join(",");

console.log(idsStr);

  

posted @ 2020-01-17 14:27  青瑟少年  阅读(5287)  评论(0编辑  收藏  举报