On Dec 31, 2008, at 9:42 AM, pete higgins wrote:
On Wed, Dec 31, 2008 at 9:34 AM, Karl Swedberg <k...@englishrules.com> wrote:



Hi Pete,
I know you already know this, but just for completeness I thought I should mention that you need to quote not only reserved-word keys but also keys
that have a character other than alphanumeric or underscore.
Karl,

I think you mean "other than alpha or underscore" (just to
nit/completeness ;) ) Always safer to go with fully quoted, though I
tend to avoid it myself unless necessary.

var foo = { "1bar" : "is valid", 2bar:"is not", _iam:"valid too",
"this-is":"valid also" }

yes, I should have been more clear. thanks for the clarification. :-)

One more nit -- and, again, this is really meant not for you but for others who might be reading this thread: Numbers are fine in a non-quoted key as long as the key does not begin with one.

var foo = { bar1: 'is valid', 2bar: 'is not', '3bar': 'valid too' };

and, yeah, I usually put in bare keys (sans quotes) unless necessary, too. Not sure why. I guess I just like the clean look.

Cheers,

--Karl

Reply via email to