How to delete an array element in Node.js

2 Answers

0 votes
let arr = ["Node.js", "PHP", "C", "Python"];
  
delete arr[0]; // Change the element to undefined
  
console.log(arr);
  

  
/*
run:
 
[ <1 empty item>, 'PHP', 'C', 'Python' ]
  
*/
 

 



answered Apr 12 by avibootz
0 votes
let arr = ["Node.js", "PHP", "C", "Python"];
  
arr.splice(0, 1)

console.log(arr);
  
  
/*
run:
 
[ 'PHP', 'C', 'Python' ]
  
*/
 

 



answered Apr 12 by avibootz
...