简体   繁体   中英

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

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.

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. I think your problem stems from giving slice the wrong parameters.

Here is the link to the Array.prototype.slice() function: Array.prototype.slice()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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