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

added by DotNetKicks
8/10/2020 3:22:53 PM

420 Views

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


0 comments