-1

Basically I appended an object to a list every time it is created, and I have a loop that goes over this list and I want it to call the object's delete function as well as remove it from the list if this object fulfills some conditions.

I have tried adding this function into the object but calling it doesn't seem to change the length of the list.

    this.pop = function()
    {
        delete(this);
    }
imanoob
  • 19
  • 3
  • 1
    Please edit your question to include more code with expected input and output so that we may reproduce your issue. – Phix Mar 30 '21 at 22:32
  • 1
    [`delete`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete) is unlikely to be the operator you want. If you have an array, [`splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) is a method of interest. But there are questions galore on Stack Overflow about how to [remove items from arrays](https://stackoverflow.com/q/5767325), [properties from objects](https://stackoverflow.com/q/208105), and [objects from existence](https://stackoverflow.com/q/742623) – Heretic Monkey Mar 30 '21 at 22:41

1 Answers1

0

The delete operator is not a function and is used to remove properties from Objects (Source)

It's not super clear what you're trying to do exactly, but you have a couple options for removing an Object from an Array.

Hope this points you in the right direction! :)

zk_
  • 71
  • 3