Wait for nested JS promise to finish before resolving original promise
问题 I am new to Promises and I'm having a little trouble with the concept of waiting for a nested promise to finish all executions before resolving the original promise. Original Code function getSomething(text) { return new Promise(function (resolve, reject) { getElse(text).then(function (items) { if (items.length !== 0) { /* Stuff here */ getElseElse(box).then(function (moreItems) { /* Stuff here */ return array; }.then(function (array) { var promise = new Promise(function (resolve, reject) { /