Javascript 承诺/A+;使用chain then()回调用例?

Javascript 承诺/A+;使用chain then()回调用例?,javascript,promise,es6-promise,Javascript,Promise,Es6 Promise,我刚开始阅读有关Promise/A+的文章,想亲自尝试一下。 我添加了多个then() 1) 然后,链接不会返回相同的承诺 > new Promise(function(a, r) {a('hello')}). then(function(r) { console.log('1', arguments) }). then(function(r) { console.log("2", arguments) }) 1 ["hello"] 2 [undefin

我刚开始阅读有关Promise/A+的文章,想亲自尝试一下。 我添加了多个
then()

1) 然后,链接不会返回相同的承诺

  > new Promise(function(a, r) {a('hello')}).
      then(function(r) { console.log('1', arguments) }).
      then(function(r) { console.log("2", arguments) })
  1 ["hello"]
  2 [undefined]
2) 没有像我预期的那样进行链接

> p = new Promise(function(a, r) {a('hello')}); 
    p.then(function(r) { console.log('1', arguments) }); 
    p.then(function(r) { console.log("2", arguments) })
1 ["hello"]
2 ["hello"]

场景#1的用例是什么?

您只需从promise返回值即可

newpromise(函数(a,r){a('hello')})。
然后(函数(r){
log('1',参数);
返回r;
}).

然后(函数(r){console.log(“2”,arguments)})
then
方法的返回值是!不要问用例链接的用例,让我们轮流表:给我一个例子来说明承诺,我将告诉你为什么需要使用链接。@ Bergi,所以,可能把这个问题当作复制品?@格伦迪:我不认为它是复制品。你能推荐一个目标吗?@Bergi,我考虑了你上面评论中的问题,因为这里似乎是关于promisesThanks的同一个常见问题,感谢你指出,但我必须仔细阅读你的答案三遍,你能不能改进一点,让其他人也能受益?@hakunin,我不太明白我到底应该如何改进它,你能解释一下吗?“你应该从承诺中返回值。”这不是很好的描述。代码格式也到处都是,您也会丢失输出。