Return a Default Value with Promises Using catch
catch to set a default value instead of a
// Instead of wrapping this block in a try/catch...
const result = await new Promise(
(resolve, reject) => reject("Because Stone Cold said so")
// ...use catch to set the default value (100)
.catch(() => 100);
As a trick I really like what's this brings; as far as readability and maintenance, if you don't know the trick, you might get confused. What do you think?
new Element Madness
The first way to create UI-driven...
With CSS border-radius, I showed you how CSS can bridge the gap between design and development by adding rounded corners to elements. CSS gradients are another step in that direction. Now that CSS gradients are supported in Internet Explorer 8+, Firefox, Safari, and Chrome...
We all know that you can make shapes with CSS and a single HTML element, as I've covered in my CSS Triangles and CSS Circles posts. Triangles and circles are fairly simply though, so as CSS advances, we need to stretch the boundaries...