How to make the length of an Array read-only in JavaScript

Sometimes, you may come across a requirement that once the array is created, its length should not be changed. In this blog post, let us explore how you can achieve that. Let us say you have an array as shown below, let foo = ['1', '11']; console.log(foo.length); // 2 console.log(foo[1]); //11 As you see, the length of the array is 2, and … Continue reading How to make the length of an Array read-only in JavaScript

The simplest way to Remove Duplicate Items from a JavaScript Array

You may have often come across a requirement to remove duplicate items from a JavaScript array. There are multiple ways to achieve it. Such that, Using the forEach loop and manually checking for the duplicate valuesUsing the array’s filter method and othersUsing the Set object Let us say; you have an array as below, let … Continue reading The simplest way to Remove Duplicate Items from a JavaScript Array

How to find index of an item in JavaScript Object Array?

Recently while working I came across a scenario. I had to find index of a particular item on given condition from a JavaScript object array. In this post we will see how to find index of object from JavaScript array of object. Let us assume we have a JavaScript array as following, Now if we … Continue reading How to find index of an item in JavaScript Object Array?

Performance of Non-Zero lower bound Single Dimensional Array

Today while returning from office, I had a very good conversation with one of mine friend Sunny Raheja. We were discussing here and there and suddenly he asked to me “Hey DJ, is there any difference in performance of single dimensional array if I don’t give lower bound as 0 or if lower bound is … Continue reading Performance of Non-Zero lower bound Single Dimensional Array