atoo
v2025.4.17
Published
array to object | Convert any array to object with/without given key-prefix.
Readme
atoo: array to object
Convert any array to object with/without given key-prefix.
npm install atooUsage
// var {arrayToObject} = require('atoo');
import {arrayToObject} from "atoo";
const obj = arrayToObject(array [, keyPrefix]);arrayToObject([1, 2, 3, "a", , , , "b"], "i-");
// Object {i-0: 1, i-1: 2, i-2: 3, i-3: "a", i-7: "b"}
arrayToObject([1, 2, 3, "a", , , , "b"]);
// Object {0: 1, 1: 2, 2: 3, 3: "a", 7: "b"}Note: Takes care of sparse arrays too.
License
The MIT License (MIT)
Copyright (c) 2016-2025 Anubhav Saini
