If a thenhandler does not have an instruction return, the resulting whole promise takes a value undefinedin bluebird. But I do not see anywhere that it is indicated in Promises / A + or anywhere? Can this behavior be calculated?
then
return
undefined
Here's the test program:
var Promise = require('bluebird'); var p = Promise.resolve('test'); p.then(function(s) { console.log('s1='+s); // no return }).then(function(s) { // bluebird prints "undefined". is this specified by a standard? console.log('s2='+s); });
Promises / A + indicates the use of the callback return value to resolve the promise.
, throw ( " ", spec-), . return, undefined. 9.2.1.
throw
, bluebird. , undefined, JS.
" JS". .
Source: https://habr.com/ru/post/1627179/More articles:Как я могу загружать таблицу, столбцы которой не должны быть разбиты? - htmlCode abbreviation with several similar "bye" values - pythonReaction + problems with Webpack - reactjsRuby - File for Enumerations - enumsMass update with Python elasticsearch - pythonPromises с http.get node.js - javascriptOvercoming the 1000+ node limit for cq nodes: Page in AEM 6.1 - adobePrismJS: centering selected lines vertically - javascriptSQLAlchemy: hybrid_property expression and subquery - pythonWhere is SP_EXECUTESQL defined? - sql-serverAll Articles