📌  相关文章
📜  如何从数组中删除元素javascript代码示例

📅  最后修改于: 2022-03-11 15:04:23.548000             🧑  作者: Mango

代码示例6
let myArray = [3, 1, 4, 1, 5, 2];
let unwantedElementIndex = 3;

// This line removes 1 element from the array, starting at the unwantedElementIndex
myArray.splice(unwantedElementIndex, 1);

// If you have your custom test to remove an element just go for 
// Higher-Order functions
let myArray = ["someone@example.com", "wrong@email@format.com", "..."];
const emailRegexp = ____;
let allCorrectEmails = myArray.filter(element => emailRegexp.test(element));