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 125 views
1 answer 125 views
1 answer 172 views
2 answers 157 views
2 answers 146 views
2 answers 176 views
...