Path: csiph.com!feeder.erje.net!1.eu.feeder.erje.net!news.roellig-ltd.de!news.mb-net.net!open-news-network.org!.POSTED.63.227.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: using Map Date: Wed, 13 Jun 2018 18:47:44 +0200 Organization: PointedEars Software (PES) Lines: 28 Message-ID: <18902741.ZdnXStS6ea@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit Injection-Info: gwaiyur.mb-net.net; posting-host="63.227.197.178.dynamic.wless.zhbmb00p-cgnat.res.cust.swisscom.ch:178.197.227.63"; logging-data="1722"; mail-complaints-to="abuse@open-news-network.org" User-Agent: KNode/4.14.2 Cancel-Lock: sha1:m1S2UUTWnpxIKfMtZLQPwuWuN3E= X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. let objArray = new Map(); > > objArray.set(0, { id:0, name:'Jonah', otherProp:321 }); > objArray.set(1, { id:1, name:'Andrew', otherProp:648 }); > objArray.set(2, { id:2, name:'Another', otherProp:850 }); > objArray.set(3, { id:3, name:'Quite', otherProp:146 }); > objArray.set(4, { id:4, name:'Mary', otherProp:984 }); DRY: let objArray = [ {id: 0, name: 'Jonah', otherProp:321}, {id: 1, name: 'Andrew', otherProp:648}, {id: 2, name: 'Another', otherProp:850}, {id: 3, name: 'Quite', otherProp:146}, {id: 4, name: 'Mary', otherProp:984} ]; let map = new Map(objArray.map((el) => [el.id, el])); -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.