You can convert an array to an object with the same data using spread(...) operator.
var fruits = ["banana", "apple", "orange", "watermelon"]; var fruitsObject = { ...fruits }; console.log(fruitsObject); // {0: "banana", 1: "apple", 2: "orange", 3: "watermelon"}