Splice

Splice function in JavaScript

The splice function in JavaScript is used for adding, removing and returning elements from an array. Let us suppose we have an array var a=new Array(1,2,3,4,5); Splice with one parameter: This returns the elements of the array starting at the parameter. var b=a.splice(0); b=1,2,3,4,5. a=var b=a.splice(2): b=3,4,5 a=1,2 Splice with 2…