bunny10245
bunny10245

Reputation: 115

How do i call dispose method(if it exists) on all objects being GC'ed in javascript

I want to call dispose method on every object in javascript when all it's references are removed, if the method exits in that object. How do I do it?

Upvotes: 0

Views: 498

Answers (1)

Yichong
Yichong

Reputation: 727

Low-level languages, like C, have low-level memory management primitives like malloc() and free() . JavaScript values are allocated when things (objects, strings, etc.) are created and "automatically" freed when they are not used anymore.
There is no dispose method in javascript, but you can use the delete operator to delete a property from an object as long as the property is configurable.

Upvotes: 2

Related Questions