The accepted answer for How do I convert an existing callback API to promises? has this example:
function getUserDataAsync(userId){
return new Promise(function(resolve,reject){
getUserData(userId,resolve,reject);
});
}
Questions:
Shouldn't the body of
Promisereturn something, not just callgetUserData(at least in practical code, not as promise demonstration exercise)?Is this particular
Promisealso a closure? It seems like it closes overuserId, asgetUserDataAsynccreates and returns a newPromiseinstance usinguserId, but I want to be sure.