How to remove specific element from an array in Node.js

1 Answer

0 votes
const arr = ['node.js', 'php', 'python', 'c', 'c++', 'c#'];
 
const index = arr.indexOf('python');
  
if (index !== -1) {  
    arr.splice(index, 1);
}
 
console.log(arr); 
   
   
     
       
       
/*
run:
       
[ 'node.js', 'php', 'c', 'c++', 'c#' ]
       
*/

 



answered Jul 4, 2022 by avibootz

Related questions

1 answer 210 views
1 answer 215 views
1 answer 263 views
2 answers 277 views
2 answers 266 views
2 answers 308 views
...