How to Convert Array Into Object In Jquery?




Hi Guys,

In this example,I will learn you how to convert array into object in can easy and simply convert array into object in jquery.

We will use Object.assign() for converting array into json object using jquery. we have to just pass object as argument in Object.assign().let's bellow example.

Example :

<!DOCTYPE html>



<title>Jquery Array to Object Convert -</title>




var myArray = [







var myObject = Object.assign({}, myArray);






{0: "apple", 1: "banana", 2: "orange", 3: "mango", 4: "pineapple"}

0: "apple"

1: "banana"

2: "orange"

3: "mango"

4: "pineapple"

It will help you...