@empathyco/x-components
Version:
Empathy X Components
61 lines (29 loc) • 1.08 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [arrayToObject](./x-components.arraytoobject.md)
## arrayToObject() function
Reduce an array of strings to an object which properties names are the value of each string, and the value under that property are also the string.
**Signature:**
```typescript
export declare function arrayToObject(array: string[]): Record<string, string>;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
array
</td><td>
string\[\]
</td><td>
Array of strings that will be used to create the object.
</td></tr>
</tbody></table>
**Returns:**
Record<string, string>
New object which properties object\[key\] contains object of each iteration in the array.
## Example
Converting an array to an object: arrayToObject(\['a', 'b', 'c'\]) === {<!-- -->a: 'a', b: 'b', c: 'c'<!-- -->}