You can map your array of indexes to their corresponding values from your name array using .map()
:
const names = ['John', 'Paul', 'George', 'Ringo']
const nums = [3, 1, 2, 0];
const res = nums.map(i => names[i]);
console.log(res);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…