How to remove all items from specific index in Node.js

2 Answers

0 votes
const arr = ['node.js', 'php', 'python', 'c', 'c#', 'c++', 'go', 'css', 'java', 'python'];
   
const index = 5;
  
arr.splice(index);
   
console.log(arr); 
 
   
   
   
/*
run:

[ 'node.js', 'php', 'python', 'c', 'c#' ]
   
*/

 



answered Jul 7, 2022 by avibootz
0 votes
const arr = ['node.js', 'php', 'python', 'c', 'c#', 'c++', 'go', 'css', 'java', 'python'];
   
const index = 5;
  
arr.length = index;
   
console.log(arr); 
 
   
   
   
/*
run:

[ 'node.js', 'php', 'python', 'c', 'c#' ]
   
*/
   

 



answered Jul 7, 2022 by avibootz

Related questions

1 answer 117 views
1 answer 132 views
1 answer 128 views
2 answers 147 views
2 answers 154 views
1 answer 123 views
...