Answers for "delete[] array"

282

how do you remove a remove element from array in javascript

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
7

c++ delet from memory

// Delete pointer
int* ptr1 = new int;
delete ptr1;

// Delete array
int* array = new int[10];
delete[] array;
Posted by: Guest on March-09-2020
9

remove elements from array js

const array = [2, 5, 9];

console.log(array);

const index = array.indexOf(5);
if (index > -1) {
  array.splice(index, 1);
}

// array = [2, 9]
console.log(array);
Posted by: Guest on June-15-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language