• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

HIVE

GhostWolf
GhostWolf
Again, it's not what you think it is. :)

HTMLElement.prototype.remove() removes the element from the DOM.

If you want to delete a variable from an object, use the "delete" operator (unless of course you are using a structure that supports delete(), like Map etc.)

delete this.tag;
console.log(this.tag); // => undefined

See more at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete
GhostWolf
GhostWolf
By the way, I am always happy to help people with programming, however for your own benefit, I really suggest you start using google (or just MDN directly for syntax rather than logic questions).

Being able to search for information is a very important ability, even more so for programming.
GhostWolf
GhostWolf
You really don't want to get stuck for hours, hoping for some internet stranger to save you, for every error you make.
Because you will make many, many errors, as do we all :p
Chaosy
Chaosy
I actually wanted to remove it from the DOM
And I know why it did not work now, I found out by mistake.
remove() does not exist, it would be without the ().
GhostWolf
GhostWolf
Chaosy
Chaosy
Well me using the function remove() did not do anything on a visual level, however if I remove the "()" I can no longer see it at least as it successfully gets removed.
Would using delete fix the issue of it not being deleted properly?
GhostWolf
GhostWolf
I doubt it is being removed properly from the DOM, delete() is a function, not a member.
If it is being deleted, it must be some other piece of code?

What do you mean deleting "properly"? again, removing elements from the DOM doesn't mean deleting them, you just remove leaf nodes from the DOM tree.
Top