The first example in Nullish Coalescing Operator the values should be switched around the ||s
You have 'value not falsey' || undefined which should actually be undefined || 'value not falsey', otherwise "value not falsey" will always show even for a truthy value.
('value not falsey' || true) === 'value not falsey'
I think it's worth noting that your dynamic import example relies on top-level await.
I think this is still a proposal isn't it?
Anyhow, probably worth-while not complicating your example with it. :)
Hy pentacular. Thanks for the reply and I agree with you. I've changed the example so it better fit the main explanation.
I love the dynamic import feature, I use it to dynamically import CSS 😃
Thank you for your blog post, a nice read and summary 👍
Thanks for reading David :)
Didn't we already have a Promise.all() what's the difference
Yes, we did. The difference is that Promise.all() didn't resolve the promises from array in then if it had at least one rejected.
Promise.all([Promise.resolve('resolved'), Promise.reject('rejected')]).then((r) => console.log(r)).catch(() => console.log('catch here!'));
Output
// catch here!
Promise.allSettled([Promise.resolve('resolved'), Promise.reject('rejected')]).then((r) => console.log(r)).catch(() => console.log('catch here!'));
Output
// [
// { status: "fulfilled", value: 'resolved' },
// { status: "rejected", reason: 'rejected' }
// ]
Ohh cool thanks for clarifying :))
The first example in Nullish Coalescing Operator the values should be switched around the
||
sYou have
'value not falsey' || undefined
which should actually beundefined || 'value not falsey'
, otherwise"value not falsey"
will always show even for a truthy value.('value not falsey' || true) === 'value not falsey'
BigInt looks interesting.
I like the optional chaining feature.
Thanks for reading Ephraim :)
Great article, there's a typo in Promise.AllSettled example, 2nd line: first "Promise.resolve"
Thanks for the reply Rajika. I've fixed the typo.