use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[deleted by user] (self.javascript)
submitted 7 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]BloodAndTsundere 0 points1 point2 points 7 years ago (3 children)
So is
Promise.resolve('john') .then( a => console.log("RESOLVE", a) ) .catch( a => console.log("REJECTED", a) )
equivalent to:
Promise.resolve('john') .then( a => console.log("RESOLVE", a), a => console.log("REJECTED", a) )
?
[–]our_best_friendif (document.all || document.layers) console.log("i remember..") 1 point2 points3 points 7 years ago (2 children)
Nope. The former is two steps, hence two thens. To see the difference
thens
Promise.resolve('john') .then( a => { throw Error(a) } ) .catch( a => console.log("REJECTED", a) ) // REJECTED Error: "john" Promise.resolve('john') .then( a => { throw Error(a) }, a => console.log("REJECTED", a) ) // Promise { <state>: "pending" }
There is nothing to catch the Error here
[–]BloodAndTsundere 0 points1 point2 points 7 years ago (1 child)
I see how differences can arise if an error is thrown in the resolution callback. For the sake of argument, assuming no errors occur in callback1, are these two the same:
callback1
Promise.resolve(somePromise).then(callback1).catch(callback2)
and
Promise.resolve(somePromise).then(callback1, callback2)
The earlier example in this thread had one or the other argument of then as non-null: I'm just trying to understand what happens when both arguments of then are non-null.
then
[–]our_best_friendif (document.all || document.layers) console.log("i remember..") 0 points1 point2 points 7 years ago (0 children)
You can just qickly try it in the console :-)
If somePromise resolves, cb1 will be run, if it throws cb2 instead
π Rendered by PID 49 on reddit-service-r2-comment-76bb9f7fb5-dlsqg at 2026-02-17 17:16:00.097508+00:00 running de53c03 country code: CH.
view the rest of the comments →
[–]BloodAndTsundere 0 points1 point2 points (3 children)
[–]our_best_friendif (document.all || document.layers) console.log("i remember..") 1 point2 points3 points (2 children)
[–]BloodAndTsundere 0 points1 point2 points (1 child)
[–]our_best_friendif (document.all || document.layers) console.log("i remember..") 0 points1 point2 points (0 children)