Insert an item inside array at specific index in ES6 Javascript

2 years ago23k times

This example is to insert an item inside an array at a specific location using ES6 Javascript

var arr = ["Hello","Hanko","Samsi","John","Nick"];
console.log(arr.join()); // Hello,Hanko,Samsi,John,Nick
arr.splice(3, 1, "Marry");
console.log(arr.join()); // Hello,Hanko,Samsi,Marry,Nick



Add Answer

Add a codeAdd Code
Remove adsremove

Latest codes

view all

Latest Snippets

view all