JavaScript array.splice() Function

JavaScript Logo

array.splice() – Adds/Removes elements **in place** and returns the removed elements.

๐Ÿ‘‰ Syntax

removed = array.splice(start, deleteCount, item1, ...);

๐Ÿงช Example

const a=[1,2,3]; a.splice(1,1,'B'); // a=[1,'B',3]

Comments