SOURCE

let aFilesList = [];

function fnInit() {
    aFilesList = [];
    fnGetFileList([2,4,3]);
}

async function fnGetFileList(arr = []) {
    for(let i = 0; i < arr.length; i++) {
        await fnGetInfo(arr[i]).then((nId)=> {
            aFilesList.push(nId);
            if(i === arr.length - 1) {
                console.log(aFilesList);
            }
        })
    }
}

function fnGetInfo(id) {
    return new Promise((resolve) => {
        resolve(id);
    })
}


fnInit();
fnInit();
console 命令行工具 X clear

                    
>
console