如果数组包含特定值,我想从数组中删除元素。
var array = [hello@yahoo.com, www.hello.com, hello@gmail.com];
我想删除带有@符号的al元素。当我向阵列发出警报时,我只需要 www.hello.com。
最佳答案
array.forEach(function(element, key) {
if (element.indexOf('@') !== -1) {
array.splice(key, 1);
}
});
关于javascript - 如果数组中包含特定字符,如何删除该元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41311158/