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 116 views
1 answer 119 views
1 answer 162 views
2 answers 149 views
2 answers 137 views
2 answers 168 views
...