Tag: Array
-
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…
-
Video – Remove Duplicate items from a JavaScript array
This video explains simplest way to remove duplicate items from a JavaScript array. Video shows to use, filter method Set object
-
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 values Using the array’s filter method and others Using the Set object Let us say; you have an array as…
-
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…
-
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…