UNPKG

@empathyco/x-components

Version:
31 lines (17 loc) 945 B
<!-- 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.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&lt;string, string&gt; 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'<!-- -->}