<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [arrayToObject](./x-components.arraytoobject_1.md)

## arrayToObject() function

Reduce an array of objects to an object which properties names are the value of each object\[key\], and the value under that property are each object. 'key' is the the parameter passed to this function.

**Signature:**

```typescript
export declare function arrayToObject<ArrayType>(array: ArrayType[], key: PropsWithType<ArrayType, string | number>): Record<string, ArrayType>;
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  array | ArrayType\[\] | Array of objects that contains objects which have object\[key\] string as a property value. |
|  key | [PropsWithType](./x-components.propswithtype.md)<!-- -->&lt;ArrayType, string \| number&gt; | Key used to access to each object\[key\] value, used for each property name in the new object. |

**Returns:**

Record&lt;string, ArrayType&gt;

New object which properties object\[key\] contains object of each iteration in the array.

