Using Array.splice() for Removing/Adding Elements in Javascript


Remove or add elements within an array.

Source Code

let fruits = ["Apple", "Banana", "Orange", "Mango"];
fruits.splice(2, 1, "Lemon", "Kiwi");
console.log(fruits); // ["Apple", "Banana", "Lemon", "Kiwi", "Mango"]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments