How to remove the last 2 elements from an array in Node.js

1 Answer

0 votes
const arr = ['javascript', 'python', 'typescript', 'node.js', 'c++', 'c'];
 
arr.splice(arr.length - 2, 2);
 
console.log(arr); 
 
   
   
   
   
/*
run:
   
[ 'javascript', 'python', 'typescript', 'node.js' ]

*/

 



answered Jun 11, 2022 by avibootz

Related questions

...