You could take those IDs into an array, and then map that array to the code you listed in your question. For example:
function getPages(ids) {
return ids.map(id => $entitites.get(id).currentPage);
}
// example call:
let pages = getPages(["123", "146", "195"]);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…