In this tutorial we are going to learn about the new features we can use in the latest version of ECMAScript 2021 with some coding examples
...
For further actions, you may consider blocking this person and/or reporting abuse
Great post, Faithful!
The numeric separators are extremely handy, love them. I'll be using private methods a lot.
By the way, if someone is asking why JavaScript uses the
#
symbol for its private properties and not theprivate
keyword, in this comment from the ECMA committee they explain why.Thanks for pointing that out I forgot to include that in this post.
Great Post !
Can you please explain the difference between
Promise.race and Promise.any ?
They booth act the same ? Does Promise.race have been deprecated ?
They are a bit different
Promise.race is resolved as soon as any of the promises you feed it resolves, whether they are fulfilled or rejected. Promise.any is settled as soon as any of the promises you feed it is fulfilled or all the promises are rejected. If all promises are rejected it returns an AggregateError.
So Promise.race returns a promise that is settled regardless it being resolved or rejected. But promise.any will not return if one promise is rejected. It will continue until the first resolved promise. If in any case none of the promises resolves then it returns an AggregateError.
I hope I cleared your confusion
Promise.race() isn't deprecated either.. They have different use cases
WHEN does Promise.any throw an error ? how can it know that none of the promise will be resolved later ?
did you mean that when ALL promises are rejected an exception is thrown ? that isn't exactly the same
When you use
Promise.any
, your literally saying which ever promise resolves first. It would only throw an error if non resolves.If you want to make sure all your promise resolves or you want to catch error when any of the promises is rejected you should use
Promise.all
insteadNice Post
Finally Promise.any solve my error handling easily! ( 0 )
Seems like I'll be using the replace all method frequently, and the numeric separators will come in really handy... A detailed, well written, explanatory post. Keep it up!
Very true the replaceAll method and the numeric separators were really needed.
I see myself using the private methods and accessors alot
Running the code above gives me Invalid character: '#'
Update your chrome browser if thats what you are using.
it was a great article thanks
Quite informative. I got to learn about the new operators, kinda tricky though, the Promise.all also looks very promising.