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 216 views
1 answer 249 views
1 answer 234 views
2 answers 267 views
2 answers 279 views
1 answer 218 views
...