Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

splice js

// splice method 
// replace Mongo as olive using splice 
const FRUITS = ["Banana", "Orange", "Lemon", "Apple", "Mango"];


let  ind=FRUITS.indexOf("Mango");

console.log(ind); // 4
console.log(FRUITS.splice(ind,1,'olive')); //deleted data is [ 'Mango' ]
console.log(FRUITS); // [ 'Banana', 'Orange', 'Lemon', 'Apple', 'olive' ]
Source by www.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #splice #js
ADD COMMENT
Topic
Name
4+9 =