469,315 Members | 1,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,315 developers. It's quick & easy.

Accessing Numeric Fields in Objects with Dot Notation

Let's say I have the following code:

var o = {"field1" : "value1", 10 : "value10"};

Now, if I say o.10
that does not work with any browser. Why exactly is this an error?

(in particular, could anyone please refer me to any authoritative
source that defines how little things like these should work? I
understand that I could have used o[10] and that would work)

Oct 8 '07 #1
1 1167
Lee
Debajit Adhikary said:
>
Let's say I have the following code:

var o = {"field1" : "value1", 10 : "value10"};

Now, if I say o.10
that does not work with any browser. Why exactly is this an error?

(in particular, could anyone please refer me to any authoritative
source that defines how little things like these should work? I
understand that I could have used o[10] and that would work)
In these specs:
http://www.ecma-international.org/pu...s/Ecma-262.htm

You'll find that an identifier must begin with one of:
A letter
An underscore
A dollar sign
A Unicode escape sequence
--

Oct 8 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Gaubitzer Erwin | last post: by
6 posts views Thread by Chris Styles | last post: by
17 posts views Thread by William L. Bahn | last post: by
14 posts views Thread by johnsobd | last post: by
3 posts views Thread by judy.j.miller | last post: by
3 posts views Thread by Otto Wyss | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.