Answers for "pop particular value from array"

282

remove a particular element from array

var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");//get  "car" index
//remove car from the colors array
colors.splice(carIndex, 1); // colors = ["red","blue","green"]
Posted by: Guest on July-19-2019
1

remove a value from array js

const index = array.indexOf(item);
if (index > -1) {
	array.splice(index, 1);
}
Posted by: Guest on December-04-2020
0

js pop matched value in array

<script type="text/JavaScript">

    var arr = [5, 15, 110, 210, 550];
    var index = arr.indexOf(210);

    if (index > -1) {
       arr.splice(index, 1);
    }

</script>
Posted by: Guest on August-23-2021

Code answers related to "pop particular value from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language