JavaScript

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...

Enforcing coding standards using husky pre-commit hooks

Enforcing coding standards using husky pre-commit hooks

  • June 5, 2021

Having consistency and enforcing coding standards becomes very important as an application scales. It becomes important to automate the process to ensure quality standards and make the application maintainable. ESLint and Prettier can be used to define these standards, but we also need a tool to enforce them. Husky provides...

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...

Object initialization shorthand notations in JavaScript

Object initialization shorthand notations in JavaScript

  • February 2, 2021

I was recently working on a project in which I was trying to use a shorthand notation for destructuring assignment of a variable. I was researching different ways of getting a specific scenario to work. And while doing that research, I found that ES2015 had added 3 new object initialization...