Replies: 6 comments
-
|
但是这个用一个 utility function 就能解决啊?比如这个被无数项目引用的 https://www.npmjs.com/package/nice-try |
Beta Was this translation helpful? Give feedback.
-
|
如果能做到 rust 那种的 checked exception 设计 + ? 语法糖自动解包就很爽了。 |
Beta Was this translation helpful? Give feedback.
-
|
突然想到还是只能忽略 rejected promise。 代替 try...catch 是不可能了。try...catch 是作用在语句上的,不是一个操作符可以代替的 |
Beta Was this translation helpful? Give feedback.
-
|
刚好 execError()??.value |
Beta Was this translation helpful? Give feedback.
-
|
@chenyong 让我想起来了这个: a()??b()?+c:d是指(没有这个提案时候的情况) Nullish coalescing: a() ?? b() ? +c : d还是: (a()?) ? b()?+c : d? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
例如:
相当于:
一般来说所有的 Promise 都要处理 rejected 的情况,Node.js, Deno 遇到没有处理的 rejected Promise 甚至会退出进程。但很多时候,一些 Promise 没必要处理,这样就会出现很多多余的代码
catch(() => {})另外也能替代一些 try...catch:
相当于 :
Beta Was this translation helpful? Give feedback.
All reactions