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);
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);