Skip to content

Instantly share code, notes, and snippets.

@Rabios
Created February 19, 2021 12:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rabios/607a001fcbf59076d0d4a1f51cfab864 to your computer and use it in GitHub Desktop.
Save Rabios/607a001fcbf59076d0d4a1f51cfab864 to your computer and use it in GitHub Desktop.
JavaScript function that converts array to object
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