Skip to content
Advertisement

2-dimensional array to object (JavaScript)

I have an array, that holds a large number of two-dimensional arrays:

JavaScript

I need to convert this array into an object of the following form to send it as JSON:

JavaScript

(“s_id” should be myArray[0][0], “t_id myArray[0][1], and “type” myArray[0][2] and so on.)

How can I get the array in the desired form? Thanks in advance.

Advertisement

Answer

JavaScript

Be aware that map is not supported in IEs < 9.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement