Results 1 to 2 of 2

Thread: Const question.

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

    Default Const question.

    If you make an constant object, can one of its sub variables (or whatever they are) also be a constant?
    Code:
    const Obj = new Object ();
    Obj.subThing = new Array ();
    Is there any way to make Obj.subThing a constant?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    No, it is a property of the object. It cannot be made to be a variable either. If your problem is that you don't want the value of it to change, then you just need to determine a way to establish its value that is not itself an object and/or subject to being updated dynamically by the rest of your code. Or, depending upon the code, you may be able to make sure it doesn't get updated.

    Also, constants are not widely supported in javascript yet, their values (contrary to the supposed standard) can change.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •