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);
不忘初心,勇闯博客园,欢迎大家留言交流技术,记得关注我哦!
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);