Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

//Splice remove and add new elements in an array in javascript

const numbers = [3, 6, 4, 8, 9, 19, 15, 21, 45, 87];
const numberSplice = numbers.splice(4, 3, 1, 2, 3);
console.log(numberSplice);
//[ 9, 19, 15 ]
console.log(numbers);
// [3, 6, 4, 8, 1,2, 3, 21, 45, 87]
 
PREVIOUS NEXT
Tagged: #remove #add #elements #array #javascript
ADD COMMENT
Topic
Name
3+7 =