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 277 views
3 answers 392 views
1 answer 216 views
1 answer 255 views
1 answer 191 views
1 answer 199 views
199 views asked Sep 27, 2022 by avibootz
1 answer 239 views
...