Hacker News new | ask | show | jobs
by wiredearp 1648 days ago
new Map([[k1,v1], [k2, v2]]) can do that. Or Object.fromEntries with the same argument.
1 comments

Thanks!

You still need to create the middle datastructure ( [[k1,v1], [k2, v2]] ) but it is an improvement :)

Ah yes, true, you always need to map the things ID to the thing itself, so that middle data structure is actually quite annoying :)