Re: Stripping [ ] from JSON arrays
JJ <[email protected]> Tue, 10 Jan 2023 11:29:13 +0700
| Newsgroups | comp.lang.php,comp.lang.javascript |
|---|---|
| Organization | A noiseless patient Spider |
| Message-ID | <[email protected]> |
On Tue, 10 Jan 2023 01:17:47 -0000 (UTC), The Doctor wrote:
>
> How do I strip unnecessary [] ?
I'd use array's `reduce()` for that. e.g.
var resultObj = theArray.reduce((res, obj) => Object.assign(res, obj), {});