1

Topic: JS, the hash table with objects?

It was tangled in syntax...
The associative array of objects is necessary. Something in the spirit of:

var people = {
id:12, data: {firstName: "Mary", lastName: "Doe", age:36};
id:2, data: {firstName: "John", lastName: "Doe", age:46};
id:21234234, data: {firstName: "John", lastName: "Smith", age:16}
};

That is for everyone id which is an index in an array there is a object with concrete fields.
How it correctly to set in javascript?

2

Re: JS, the hash table with objects?

White Owl;
https://developer.mozilla.org/ru/docs/W … bjects/Map

3

Re: JS, the hash table with objects?

White Owl;

var result = [{id:12, data: {firstName: "Mary", lastName: "Doe", age:36}};
{id:2, data: {firstName: "John", lastName: "Doe", age:46}};
{id:21234234, data: {firstName: "John", lastName: "Smith", age:16}}
].reduce ((accumulator, currentValue) => {accumulator [' id ' +currentValue.id] =currentValue.data; return accumulator;}, {})