Math.sum or a likewise, baked in API. Fear not -- summing an array of numbers is easy using
const numbers = [1, 2, 3, 4];
const sum = numbers.reduce((a, b) => a + b, 0);
0 represents the starting value while with
b, one represents the running total with the other representing the value to be added. You'll also note that using
reduce prevents side effects! I'd still prefer something like
Math.sum(...numbers) but a simple
reduce will do!
One of the web components I've always loved has been Facebook's modal dialog. This "lightbox" isn't like others: no dark overlay, no obnoxious animating to size, and it doesn't try to do "too much." With Facebook's dialog in mind, I've created LightFace: a Facebook lightbox...
One of my favorite social APIs was the Open Graph API adopted by Facebook. Adding just a few META tags to each page allowed links to my article to be styled and presented the way I wanted them to, giving me a bit of control...
Many times you'll see a form dynamically change available values based on the value of a form field. For example, a "State" field will change based on which Country a user selects. What annoys me about these forms is that they'll often do an...