var list = [] var count = 0 var index = 0 var si1 = setInterval(() => { if(count<3) { var data = [...new Array(65)].map((item, index) => count + '' + index) list = [...list, ...data] console.log('input: ', list) count += 1 } else { window.clearInterval(si1) } }, 1000) var si2 = setInterval(() => { if(list[index*8]) { console.log('output: ', index*8, (index + 1)*8, list.slice(index*8, (index + 1)*8)) index += 1 } else { window.clearInterval(si2) } }, 1000)