delete() related question.
I used delete() on my object, it got "deleted" successfully but I could still console.log() the object that I removed from. I don't want to paste the code because It is allot and it will just make your life a bit harder, I (think)
let myList = new Set();
Did you try to delete an object property or an object ?
Can I please see the code fragment that deletes and the object declaration of what you are attempting to delete?
The delete operator removes a given property from an object. On successful deletion, it will return true, else false will be returned. However, it is important to consider the following scenarios:
- If the property which you are trying to delete does not exist, delete will not have any effect and will return true
- If a property with the same name exists on the object's prototype chain, then, after deletion, the object will use the property from the prototype chain (in other words, delete only has an effect on own properties).
- Any property declared with var cannot be deleted from the global scope or from a function's scope. As such, delete cannot delete any functions in the global scope (whether this is part from a function definition or a function expression).
- Functions which are part of an object (apart from the global scope) can be deleted with delete.
- Any property declared with let or const cannot be deleted from the scope within which they were defined.
- Non-configurable properties cannot be removed. This includes properties of built-in objects like Math, Array, Object and properties that are created as non-configurable with methods like Object.defineProperty().