調べてみたらこういう書き方もあるようだ。
const items = [1, 2, 3];
const boxes = [1, 2, 3];
var myPromise = Promise.resolve();
for (const item_id of items) {
myPromise = myPromise.then(update.bind(this, item_id));
}
for (const box_id of boxes) {
myPromise = myPromise.then(edit.bind(this, box_id));
}
myPromise.then(function(){
return new Promise(function (resolve, reject) {
alert("end");
resolve();
});
})