1. Use replaceAll
2. Use Logical Assignment Operators
These newly introduced operators combine the power of assignment and logic operations.
The logical x||=y works like this: if x is truthy, it returns x. Otherwise, it assigns yto x.
While x&&=only assigns yif xis truthy
3. Use Numeric separators
This is a feature I love so much. And it’s so trivial that I wonder why it hasn’t been part of the language since its first days. With numeric separators, you can separate thousands in your numbers, making them a lot more readable:
4. Use Promise.any()
The Promise.any() method resolves as soon as any of the promises you passed to it becomes resolved. Contrarly to Promise.race() , it doesn’t reject early when one of the promises rejects.
One example where this method could be useful? Retrieving resources from the fastest server.