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

2 answers 141 views
141 views asked Mar 13, 2024 by avibootz
2 answers 219 views
2 answers 197 views
1 answer 176 views
1 answer 197 views
197 views asked Jan 17, 2022 by avibootz
1 answer 146 views
...