UNPKG

@empathyco/x-components

Version:
61 lines (29 loc) 1.08 kB
<!-- 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 <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&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'<!-- -->}