I need to detect if a list changes after using filter
. Currently, I use the below code:
var bullets2 = bullets.filter((bullet) => {
return (bullet[0] < 450)
})
if (bullets2.length != bullets.length) {
bullets = bullets2
update_user_pos()
}
bullets = bullets2
But this doesn't seem very effient. Is there a better way to do this?
Seems like that is the most efficient way, though @Bergi pointed out that I could removed the end bullets = bullets2
.
New Code:
var bullets2 = bullets.filter((bullet) => {
return (bullet[0] < 450)
})
if (bullets2.length != bullets.length) {
bullets = bullets2
update_user_pos()
}