There is a dynamic website of 10 pages (it works using the history API ). When you go to the first page, a .js file is dynamically loaded that contains an object that performs certain actions on the page. It is the same for other pages, when you go to any of the 10 pages, your object is loaded with its own methods and properties.
So, it is necessary that when switching to other pages the object is permanently deleted and not hung in memory.
How to delete an object? Like this: obj = null; or obj = {};
Or is there another way, more correct?
If you delete objects using the methods I specified, after about what time will the garbage collector finally delete the objects themselves?
And another question:
If instead of an object there is a function, then how is it properly removed? So: func = null;
I would like to rely on your experience in developing dynamic applications. How would you implement the mechanism of this application?