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 6928615

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:12:42+00:00 2026-05-27T11:12:42+00:00

Do I have to destroy instances myself? …if I don’t assign them a variable…will

  • 0

Do I have to destroy instances myself? …if I don’t assign them a variable…will they automatically go away?

new ImageUploadView();

vs

var Iu = ImageUploadView();
  • 0 0 Answers
  • 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-05-27T11:12:43+00:00Added an answer on May 27, 2026 at 11:12 am

    If there is no reference to an object in javascript, the garbage collector will clean it up.

    The way the garbage collector works is it looks for javascript objects for which nobody has a reference to. If nobody has a reference to it, then it can’t be used again, so it can be deleted and the memory it occupied reclaimed. On the other hand, if any javascript entity still has a reference to the object, then it is still “in use” and cannot be deleted.

    In your first code example:

    new ImageUploadView();
    

    unless the constructor of the object stores away the this pointer into some other variable or object or creates some closure that causes references to the object to be held, then there will be no reference to this new object and it will be cleaned up by the garbage collector.

    If you second code example:

    var Iu = ImageUploadView();
    

    as long as the Iu variable exists and stays in scope it will contain whatever the ImageUploadView() function returns. Note, the second example, is just executing a function and storing it’s value. It is not necessarily creating anything. If ImageUploadView() just returns true, then that’s all the Iu variable will contain.

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

Sidebar

Related Questions

I have a library which creates objects (instances of class A) and pass them
i need to create and destroy dynamically dictionaries, or arrays, and have them as
I have an abstract class: type TInterfaceMethod = class abstract public destructor Destroy; virtual;
If I have an initialised pthread_barrier_t, when is it safe to destroy it? Is
Reading through the CKEditor documentation , I see that they have an option to
i have a modeless form. When the user is done with it, and they
Questions: Every time i open a nib, new instances of the items in the
I am new to cocoa-touch, and really unmanaged languages all together. While I have
I have developed a JSP web application which, on every request, spawns a new
I have several instances of the following HTML on a page: <div class=input radio

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.