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 183 views
3 answers 263 views
1 answer 111 views
1 answer 178 views
1 answer 127 views
1 answer 124 views
124 views asked Sep 27, 2022 by avibootz
1 answer 158 views
...