Somthing in this direction? Here jobs is undefined in the functions addJob and runNext is there the possibility to get this work?
const myThing = {
jobs: [],
addJob: (id, job) => {
jobs.push({id: id, job: job})
},
runNext: () => {
jobs.shift().job()
}
}