84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
var obj = [{id:'bg',src:'img/bg2.jpg'},{id:'logo',src:'img/logo.png'}]
怎么写成obj.bg=‘img/bg2.jpg’,而不是obj[0].src='img/bg2.jpg'
认证0级讲师
var obj={ 'bg':{'id':'bg','src':'img/img02.jpg'}, 'log':{'id':'logo','src':'img/img01.jpg'} } obj.bg.src; // 'img/img02.jpg'
var arr = []; obj.forEach(function(item){ var j = {}; j[item["id"]] = item["src"]; arr.push(j) })
可以加多点描述吗,实际意图是什么。
function func () { const ret = {} obj.forEach(item => ret[item.id] = item.src) return ret // Object {bg: "img/bg2.jpg", logo: "img/logo.png"} }
是要这样的效果?
可以加多点描述吗,实际意图是什么。
是要这样的效果?