Fork me on GitHub

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

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 @ 2019-12-06 10:09  ice_coke  阅读(12606)  评论(1编辑  收藏  举报