How to create fixed size array in JavaScript

1 Answer

0 votes
const size = 4
let arr = new Array(size)

arr[0] = 234;
arr[1] = 98;
arr[2] = 7;
      
console.log(arr);
 
 
    
    
/*
run:
    
[234, 98, 7, undefined]
    
*/

 



answered Jan 23, 2021 by avibootz

Related questions

1 answer 186 views
3 answers 267 views
1 answer 117 views
1 answer 181 views
1 answer 130 views
1 answer 128 views
128 views asked Sep 27, 2022 by avibootz
1 answer 159 views
...