Skip to content

Instantly share code, notes, and snippets.

View LuisTalavera's full-sized avatar

Luis Talavera LuisTalavera

View GitHub Profile
@thesofakillers
thesofakillers / converter.js
Last active February 26, 2024 16:15
JS: Convert Object of Arrays to Array of Objects
/**
* Converts an Object of Arrays to an Array of Objects
* @param {Object} object_arrays An object of arrays where each array is of the same length
* @returns {Array<Object>} An Array of objects where each key in each object corresponds to that element in the original array
*/
function obj_arraysTOarray_objs(object_arrays){
let final_array = object_arrays[Object.keys(object_arrays)[0]].map(
// el is unused, but needs to be defined for map to give access to index i
(_el, i) => {
let internal_object = {};