“Usuń tablicę z tablicy JavaScript” Kod odpowiedzi

JavaScript Usuń element z tablicy

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"]
Grepper

Jak usunąć element z tablicy w 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"]
Anxious Anaconda

Usuń element z tablicy w JS

var myArray = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];

//removing element using splice method -- 
//arr.splice(index of the item to be removed, number of elements to be removed)
//Here lets remove Sunday -- index 0 and Monday -- index 1
  myArray.splice(0,2)

//using filter method
let itemToBeRemoved = ["Sunday", "Monday"]
var filteredArray = myArray.filter(item => !itemToBeRemoved.includes(item))
JavascriptNinja

Usuń JavaScript elementów tablicy

let value = 3

let arr = [1, 2, 3, 4, 5, 3]

arr = arr.filter(item => item !== value)

console.log(arr)
// [ 1, 2, 4, 5 ]
Proud Pollan

Usuń JavaScript elementów tablicy

let forDeletion = [2, 3, 5]

let arr = [1, 2, 3, 4, 5, 3]

arr = arr.filter(item => !forDeletion.includes(item))
// !!! Read below about array.includes(...) support !!!

console.log(arr)
// [ 1, 4 ]
Proud Pollan

Usuń tablicę z tablicy JavaScript

myArray = myArray.filter( ( el ) => !toRemove.includes( el ) );
Lively Ladybird

Odpowiedzi podobne do “Usuń tablicę z tablicy JavaScript”

Pytania podobne do “Usuń tablicę z tablicy JavaScript”

Więcej pokrewnych odpowiedzi na “Usuń tablicę z tablicy JavaScript” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu