Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to move an element of an array in javascript

function moveElement(array,initialIndex,finalIndex) {
	array.splice(finalIndex,0,array.splice(initialIndex,1)[0])
	console.log(array);
	return array;
}
// Coded By Bilal
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #move #element #array #javascript
ADD COMMENT
Topic
Name
9+6 =