By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

Accessing Numeric Fields in Objects with Dot Notation

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.