const array = [
{id: 1, value: 1},
{id: 2, value: 1.2},
{id: 3, value: 3},
];
const obj = array.reduce((sum, v) => ({...sum, [v.id]: v}), {});
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme