Filter can get you there also:
const obj = {
'#1 List title': [{
title: 'First',
},
],
'#2 List title': [{
title: 'Sec',
},
],
'#3 List title': [{
title: 'Third',
},
],
'#4 List title': [{
title: 'Fourth',
},
],
'#5 List title': [{
title: 'Fifth',
},
],
};
const start = 2;
const end = 4;
const listItem = Object.keys(obj).filter((_,i) => i >=start && i <=end).map((key) => `
<div key=${key}>
<div>${key}</div>
<div>
${obj[key].map(el =>
{el.title}
)}
</div>
</div>
`
)
console.log(listItem)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…