Results 1 to 2 of 2

Thread: Deleting Variables?

  1. #1
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default Deleting Variables?

    I think this will be my last thread for a while. Can you delete variables? Like with:

    var blah = "hi";
    delete blah;

    Or something like that? Because otherwise with a complex enough script they could pile up, unless you used one array for every var.

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ??? View Post
    I think this will be my last thread for a while. Can you delete variables?
    Properties can be deleted, at least on user-defined native objects. Properties of host objects (such as DOM objects) and most built-in properties cannot usually be deleted. Try to do so can lead to exceptions in IE (though that's a mistake, in my opinion: the operator should just return false).

    Variables - properties defined using a var declaration - cannot be deleted.

    Because otherwise with a complex enough script they could pile up, ...
    Yes, they do, though that not usually a problem. Whenever a document is unloaded, script-defined data is discarded.
    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •