How to empty an array in Node.js

2 Answers

0 votes
let arr = [1, 2, 3, 4, 8];
console.log(arr);
 
arr = [];
console.log(arr);
   
   
     
       
       
/*
run:
       
[ 1, 2, 3, 4, 8 ]
[]
       
*/

 



answered Jan 17, 2022 by avibootz
0 votes
let arr = [1, 2, 3, 4, 8];
console.log(arr);

arr.length = 0;
console.log(arr);
  
  
    
      
      
/*
run:
      
[ 1, 2, 3, 4, 8 ]
[]
      
*/

 



answered Jan 17, 2022 by avibootz

Related questions

...