JavaScript

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

How to cancel an HTTP fetch request

How to cancel an HTTP fetch request

  • January 19, 2021

JavaScript promises have been a huge catalyst for asynchronous coding in the language. They have vastly improved the performance and experience for web development. One shortcoming of native promises has been that we were not able to cancel an HTTP fetch request once it was initiated. But now there is...

How to unit-test a private (non-exported) function in JavaScript

How to unit-test a private (non-exported) function in JavaScript

  • November 19, 2020

When writing unit-tests for JavaScript modules, we often encounter a dilemma wherein the module has some private functions that have not been exported. Testing a function that has been exported is easy since it can be imported in the unit testing framework, and the functionality can be tested. But how...

The new Logical Assignment Operators in JavaScript

The new Logical Assignment Operators in JavaScript

  • October 8, 2020

The latest version of ECMAScript introduced three new logical assignment operators: nullish, AND, and OR operators. These are supported from Firefox 79 onwards, Chrome 85 onwards, and naturally there is no IE support but since Edge is now chromium based, it is available there too. They are not available in...

How to groupby using reduce in JavaScript

How to groupby using reduce in JavaScript

  • October 1, 2020

The groupBy method is one of the reasons people use lodash in their project. In this blog post, we will write our own version of groupBy using reduce and vanilla JavaScript. What groupBy does? groupBy works on an array of items, and it groups these items together into an object...

JavaScript Promise combinators: race, all, allSettled, any

JavaScript Promise combinators: race, all, allSettled, any

  • December 3, 2019

Promises have not been a new concept in the javascript community. They have existed in the ecosystem for a long time. JavaScript promises existed even before they were officially made a part of the ECMAScript spec in ES6. These initial implementations of JavaScript promise were in the form of framework...

How to import/export ES6 modules in Node

How to import/export ES6 modules in Node

  • June 19, 2018

If you have been following the javascript ecosystem for a while, you already know that even though ES6 modules are a thing, you still cannot import/export ES6 modules in node.js as of today. Node 10 experimental flag for importing/exporting ES6 modules in Node Though Node 10 has added an experimental...