How does the `Promise.resolve()` static method handle arguments of the Function type?
I hope you will ignore the English grammar mistakes. I am learning JavaScript Promises by reading MDN docs, while learning a static method of the Promise class Promise.try() I read the following statement. Source You may have an API that takes a callback. The callback may be synchronous or asynchronous. You want to handle everything uniformly by wrapping the result in a promise. The most straightforward way might be Promise.resolve(func()). The problem is that if func() synchronously throws an error, this error would not be caught and turned into a rejected promise. (MDN Docs) They didn't ment
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.