My apologies if this question has been asked before, but I searched online first and couldn't find a helpful answer.
Beautiful Views
Recently, I was working on a project where I needed to display search results, each accompanied by a button that triggers tooltips. The code I had seemed to be working fine, and here is a simplified version:
let searchAndDisplayResults = (function () {
let tooltips;
return (key) => {
// code for handling search results goes here
// tooltip functionality also included
}
})();
Please note that I have used the tooltip functionality from here.
Whenever a new search key is provided, the old search results are cleared and new ones are displayed. However, I noticed that the variable tooltips
is not being deleted each time the search results are refreshed.
Question
Considering browser memory usage, I am curious if it is necessary to delete the tooltips array every time new search results are rendered. Should I add code like the following to clear the tooltips
variable before displaying new results?
if (tooltips != null) {
for (let tooltip of tooltips) {
delete tooltip;
}
}