Writing good code is important — writing code that’s easily human readable is a next level skill. It’s not often that APIs are introduced whose seemingly only useful function is making code more readable, but let me introduce you to JavaScript numeric separators: an API that lets developers use underscores to make numbers more readable!
Consider the following number in your code:
// No commas for numbers in JavaScript const oneHundredThousand = 100000;
Large numbers have always been difficult to mentally parse for engineers, so using underscores to make code more readable is a total win:
const oneMillion = 1_000_000; // 1000000 const decimals = 1_000_00.01_02_03 // 100000.010203
The only real rule with numeric separators is that the number cannot start or end with an underscore.
Numeric separators within JavaScript seem like spec creators gifting developers a feature. As an engineer, I’ll take all I can get. You never stop learning in the world of JavaScript!
Camera and Video Control with HTML5
Client-side APIs on mobile and desktop devices are quickly providing the same APIs. Of course our mobile devices got access to some of these APIs first, but those APIs are slowly making their way to the desktop. One of those APIs is the getUserMedia API…
MooTools CountDown Plugin
There are numerous websites around the internet, RapidShare for example, that make you wait an allotted amount of time before presenting you with your reward. Using MooTools, I’ve created a CountDown plugin that allows you to easily implement a similar system. The MooTools JavaScript The CountDown class…
MooTools Zebra Table Plugin
I released my first MooTools class over a year ago. It was a really minimalistic approach to zebra tables and a great first class to write. I took some time to update and improve the class. The XHTML You may have as many tables as…