Quick Tips Tutorials
JavaScript waitForTime
I write a lot of tests for new features within Firefox DevTools. We have hundreds of "mochitests" which open the browser and perform synthetic actions like clicking, typing, and other user actions. I've previously written about
waitForever
which essentially halts following actions without locking the...Reverse Lookups with JavaScript
I've always loved exploring regular expressions because they're one of those skills that's never taught in school -- you need to pick them up on the fly, messing up and fixing them along the way. Regex's are incredibly powerful, and one power they have are...
Promises and Static Values
Async can throw a real wrench into the cogs of our programming workflows, all despite the fact that async is the modern JavaScript pattern. While async/await helps, there's sometimes confusion about the way to have a single function that returns a value whether it exists...
Data URIs
We're all familiar with traditional URI protocols like https, http, ftp, and file, but data URIs have become a large part of our online strategy. We can use them to display images, the Mac camera and webcams, and more. But what if we simply...
then on Objects
Promises were a revelation in JavaScript development, allowing us to enjoy async processing and avoid callback hell. Many new APIs like Battery API, Cache API, and others use the promise API. One fact you may not know is that you can add...
CSS Gradient Text
Web developers know the fight we’ve all had to improve fonts on the web. Whether it be load time, odd strategies for using custom fonts (Cufon, anyone?), or just finding the right font itself, beautifying text on the web has never come easy.That got...
Detect if Element is a Web Component
I've advocated for web components since before they became a spec, mostly inspired by the Dojo Toolkit's dijit framework. Empowering first class JavaScript widgets, as opposed to a mess of DIVs and templates, always made the most sense. Now that web components exist, and awesome...
Recursive Array.flat
There was much talk about
Array.prototype.flat
during its early stages, starting with the name alone. Many developers preferred the nameflatten
but the spec differed from MooTools' implementation. MooTools would recursively flatten an array but the new, officialflat
implementation defaults one level of flattening,.The current...Using Array reduce
Every developer who specializes in any programming language will tell you there's a powerful tool the language provides that they rarely use and wish they knew more about. For me, it's
Array.prototype.reduce
. I quite enjoy the otherArray
methods likemap
,filter
, andfind
...Type Conversion with JavaScript Arrays
JavaScript's loose nature allows developers to employ amazing tricks to do just about anything you'd like. I've detailed how you can filter falsy values in arrays using a
filter(Boolean)
trick, but reader David Hibshman shared another trick for typecasting array values the same...