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 276 views
3 answers 392 views
1 answer 215 views
1 answer 255 views
1 answer 190 views
1 answer 198 views
198 views asked Sep 27, 2022 by avibootz
1 answer 239 views
...