I'm learning JS and wrote this piece of code.
const functions = [
prom => {
console.log(1)
return prom
},
prom => {
console.log(2)
return prom
},
prom => {
console.log(3)
return prom
}
]
let prom = new Promise((resolve, reject) => {
resolve()
})
for(functionIndex in functions){
prom = prom.then(functions[functionIndex])
}
It executes perfectly fine but I'm not really sure it will always execute the functions I pass it in the right order (i.e. the order of the array of functions).
Am I right assuming it will always be the case?