@empathyco/x-components
Version:
Empathy X Components
31 lines (17 loc) • 945 B
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
| Parameter | Type | Description |
| --- | --- | --- |
| array | string\[\] | Array of strings that will be used to create the object. |
**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'<!-- -->}