Create fixed length array with blank values in it Javascript

Initialize an array in javascript of fixed length which has all blank values in it

var my_arr = Array(7).fill('');


In the code snippet, we have created an array which contains 7 items in it. We have used .fill() method of array to put blank values to it. You can also use custom values that you want to fill your array with. You can check a working example demo for the avove code as below.

Was this helpful?