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!
39 Shirts – Leaving Mozilla
In 2001 I had just graduated from a small town high school and headed off to a small town college. I found myself in the quaint computer lab where the substandard computers featured two browsers: Internet Explorer and Mozilla. It was this lab where I fell…
9 Mind-Blowing Canvas Demos
The
<canvas>
element has been a revelation for the visual experts among our ranks. Canvas provides the means for incredible and efficient animations with the added bonus of no Flash; these developers can flash their awesome JavaScript skills instead. Here are nine unbelievable canvas demos that…Introducing MooTools HeatMap
It’s often interesting to think about where on a given element, whether it be the page, an image, or a static DIV, your users are clicking. With that curiosity in mind, I’ve created HeatMap: a MooTools class that allows you to detect, load, save, and…
[ad_2]
Source link