javascript

Measuring JavaScript execution time

Measuring JavaScript execution time

  • July 1, 2021

When it comes to performance of applications, measuring performance becomes important. For anything to be optimized, it must be measured first, optimized, and measured again to capture gains. Measuring JavaScript execution time thus becomes one of these steps. Modern browsers and the Node.js platform provide various API’s to measure code...

Numeric Separators in JavaScript

Numeric Separators in JavaScript

  • June 16, 2021

Writing performant code is not enough as a developer. We need to ensure that it is readable as well. And it is rare that an API change in a language introduces readability. Numeric Separators are one such rare change. Why numeric Separators? Reading this takes a few seconds: Counting the...

Apply timeout to JavaScript Promises

Apply timeout to JavaScript Promises

  • June 10, 2021

JavaScript promises do not have any time associated with them. We can use a .then() function and wait until the promise is resolved or rejected. We can even await it, and either of those works if the async task finishes in a reasonable amount of time. But in the case...

Writing better conditional expressions in JavaScript

Writing better conditional expressions in JavaScript

  • March 30, 2021

Writing conditional expressions is pretty easy to do. But there is room for improvement in the way we have been doing it. And with the flexibility that JavaScript provides, we can replace conditionals with clean code by using some good practices. And it can lead to more maintainable code. Let...

Using the optional chaining operator in JavaScript

Using the optional chaining operator in JavaScript

  • March 18, 2021

Every now and then, you come across a JavaScript feature that vastly changes the way you write it. Destructuring, arrow functions, modules have been some of those features for me. Optional chaining is going to be the next one on that list for me. Optional Chaining is in stage 4...

How to format a Number as Currency using ES2015

How to format a Number as Currency using ES2015

  • March 4, 2021

The process to format a number as currency can be a tedious task. It feels like a small task, but the number of lines and the edge cases can keep on increasing when considering factors such as internationalization and different formatting standards. Luckily, ES2015 introduced an internationalization API which can...

JavaScript Proxy: What and Why?

JavaScript Proxy: What and Why?

  • February 16, 2021

EcmaScript 2015 introduced yet another feature that has not been used widely yet. A JavaScript proxy allows us to wrap an existing object with a layer. The layer can provide us with capabilities such as the interception of attributes and methods. And this can be done even if the properties...