Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript's equivalent of destruct in object model

Since I've dealt in the past with javascript's funky "object model", I assume there is no such thing as a destructor. My searches were mildly unsuccessful, so you guys are my last hope. How do you execute stuff upon instance destruction?

like image 329
php_nub_qq Avatar asked Mar 21 '14 18:03

php_nub_qq


People also ask

Does JavaScript have a destructor?

The object destructuring is a useful JavaScript feature to extract properties from objects and bind them to variables. What's better, object destructuring can extract multiple properties in one statement, can access properties from nested objects, and can set a default value if the property doesn't exist.

What is object destruction in JavaScript?

Destructuring is the process of breaking a structure. In the context of programming, the structures are the data structures, and destructuring these data structures means unpacking individual values from the data structure. In JavaScript, destructuring can be applied to an Object or an Array.

How do you call an object's destructor?

A destructor is called for a class object when that object passes out of scope or is explicitly deleted. A destructor is a member function with the same name as its class prefixed by a ~ (tilde). For example: class X { public: // Constructor for class X X(); // Destructor for class X ~X(); };


1 Answers

MDN is a nice resource for JS. No, there is nothing like calling a function when an object ceases.

like image 137
Thomas Junk Avatar answered Oct 09 '22 05:10

Thomas Junk