简体   繁体   English

JavaScript数组过滤器功能仅删除带有拼接的一个元素

[英]JavaScript Array filter function removes only one element with splice

So I want to remove two objects from array by checking its values. 所以我想通过检查数组的值从数组中删除两个对象。 There is my code - http://prntscr.com/bvqa16 有我的代码-http://prntscr.com/bvqa16

What happens is that it removes only one element from that array. 发生的是它仅从该数组中删除了一个元素。 I also tried the same thing with $.each and array.forEach, but no success. 我也用$ .each和array.forEach尝试了同样的事情,但是没有成功。

Where is the problem? 问题出在哪儿?

The slice function works with two parameters, the first being the start of where to slice (in your case, the variable i), and second being the index of how far to slice. slice函数使用两个参数,第一个是切片位置的起点(在您的情况下为变量i),第二个是切片距离的索引。 I think your problem stems from giving slice the wrong parameters. 我认为您的问题源于为slice设置了错误的参数。

Here is the link to the Array.prototype.slice() function: Array.prototype.slice() 这是Array.prototype.slice()函数的链接: Array.prototype.slice()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM