MeshWorld India LogoMeshWorld.

Convert array to an object in JavaScript

Listen to ArticleAI Speech
~1 min read narration
100%
Convert array to an object in JavaScript

During development we often came across a need of conversion an array to an object.

In this article, lets see how to convert, JavaScript array to an object quickly using widely popular and accepted spread operator (...).

Example

var fruits = ["apple", "grapes", "mangoe", "orange"];
var fruitsObject = { ...fruits };
console.table(fruitsObject);

Output for console.table

(index)Value
0“apple”
1“grapes”
2“mango”
3“orange”

Hope you like this!

Keep helping and happy 😄 coding

With ❤️ from 🇮🇳

Reader Quality Feedback

Did this technical guide help solve your problem?

Suggest Errata ($0)
Vishnu
Primary Author

Vishnu

Founder & Principal Architect at MeshWorld. Senior engineer and instructor specializing in AI agent systems, scalable web architecture, and modern development workflows.

Explore Author Archive
Compute Fuel & Open Testbed
100% Independent & Verified

Fuel High-Density, Zero-Fluff Engineering Deep-Dives

Every guide on MeshWorld is validated on physical Linux nodes and reproducible testbeds. If this article saved you hours of debugging or unblocked production, consider funding our next cluster run.

Weekly Dispatch

Join MeshWorld Dispatch

Get practical tutorials, system blueprints, and curated AI engineering notes straight to your inbox. No fluff, zero spam.

Zero spam. 1-click unsubscribe anytime.Prefer RSS?
Curated Continuations

Up Next in This Domain.

Browse Full Archive