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