MyObject = {
a : 'a',
b ; this.a
}
Sent from my BlackBerry
-----Original Message-----
From: Arian Stolwijk <[email protected]>
Sender: [email protected]
Date: Tue, 6 Dec 2011 14:34:23
To: <[email protected]>
Reply-To: [email protected]
Subject: Re: [JSMentors] Object Declaration Question
That second example doesn't work. myObj doesn't exist yet when you already
want to access myObj.a.
On Tue, Nov 22, 2011 at 8:32 PM, David Granado <[email protected]>wrote:
> Normally, if I need an object to depend on another member's value, I would
> do something like this:
>
> myObj = {};
>
> myObj.a = 'a';
> myObj.b = myObj.a + 'b';
>
> However, I've not seen this syntax used very much:
>
> myObj = {
> a : 'a',
> b : myObj.a + 'b'
> }
>
> Are there any pitfalls to this? As far as I can tell, they are 1:1.
>
> Any insight from the pros would be great.
>
> Thanks
>
> David
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
>
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]