Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7862423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:07:26+00:00 2026-06-02T23:07:26+00:00

I used to create instances of my JavaScript classes using the new keyword and

  • 0

I used to create instances of my JavaScript “classes” using the new keyword and call the constructor like: new myStuff.DoSomething(); in order to get an instance of it. Sometimes when needed I give the instance a reference like: var myObj = new myStuff.DoSomething();

I come to think about the memory management: does JS clean up the objects without references when they aren’t used anymore? – the same way it would clean up those with references. And what about all event handlers in a killed object, do they still live on?

Example: If I create, for instance, a draggable window using the new keyword and no reference to the object and then attach event handlers and so on. Then I decide to delete the window from the DOM. How can I make sure the actual object is removed as well?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:07:27+00:00Added an answer on June 2, 2026 at 11:07 pm

    Does JS clean up the objects without references when they aren’t used anymore?

    Yes. JavaScript is a garbage collected language.

    And what about all event handlers in a killed object, do they still live on?

    It depends, since we’re now talking about the DOM, and not just JS as a language. Certain DOM implementations (such as in older versions of IE) are notorious for leaking memory in this way. Other browsers/DOM implementations may not have such bugs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i used to create an instance of a singleton class like this: $Singleton =
I read here (Douglas Crockford) using prototype operator to add methods to Javascript classes
A nasty gotcha in javascript is forgetting to call new on a function meant
I guess probably the most used technique to mimic classes and class-inheritance in Javascript,
How can I emulate classes (and namespaces) in JavaScript? I need to create a
I'm using the HTML/CSS/JavaScript/jQuery to create a UI palette for a Sketchup plug-in. There
I like using Selenium RC for automating interaction with webpages that require JavaScript, except
I'm used to create query with createQuery() instead of queryBuilder, but I need to
When programming C++ we used to create copy constructors when needed (or so we
in Web Forms i used to create WeebServices and PageMethods to be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.