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?
An Interview with Eric Meyer
Your early CSS books were instrumental in pushing my love for front end technologies. What was it about CSS that you fell in love with and drove you to write about it? At first blush, it was the simplicity of it as compared to the table-and-spacer…
You’ve probably heard the talk around the water cooler about how promises are the future. All of the cool kids are using them, but you don’t see what makes them so special. Can’t you just use a callback? What’s the big deal? In this article, we’ll…