Created
February 19, 2021 12:03
-
-
Save Rabios/607a001fcbf59076d0d4a1f51cfab864 to your computer and use it in GitHub Desktop.
JavaScript function that converts array to object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arr2obj(array) { | |
var result = {}; | |
for (var i = 0; i < array.length; i++) { | |
result[(i).toString()] = array[i]; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment