Tengo el siguiente bucle for en el que se crea this_block y luego se completa:
for (i = learning_trial_idx.length - 1; i >= 0; i--) { target = Math.floor(Math.random()) these_trials = learning_trial_idx.filter(x => x.from != target) this_block = []; for (let i = 0; i < these_trials.length; i++) { this_block.push(these_trials[i]) } this_block = this_block.filter(function (a) { var key = a.to + '|' + a.from; if (!this[key]) { this[key] = true; return true; } }, Object.create(null)); } ¿Cómo puedo almacenar this_block cada vez en algo como const all_blocks = {} , que se define fuera del bucle for?
Puede hacerlo declarando first const allBlocks = { thisBlock: [] } y push -ing dentro thisBlock dentro del bucle for : allBlocks.thisBlock.push(theseTrials[i])