Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #18987
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Undottability |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <XnsA18D75C36B64eejj99@194.109.133.133> <514edd32$0$6547$9b4e6d93@newsspool4.arcor-online.net> |
| Date | 2013-03-24 19:50 +0100 |
| Message-ID | <XnsA18DC9DBF907Ceejj99@194.109.133.133> (permalink) |
Martin Honnen wrote on 24 mrt 2013 in comp.lang.javascript:
> Evertjan. wrote:
>> var a = {};
>>
>> a[''] = 9;
>> alert(a['']); // 9
>>
>> [chrome tested]
>>
>> This object property seems undottable,
>> as you cannot write it like:
>>
>> a.b = 1;
>> alert(a.b); // 1
>>
>> Strangerder js?
>
> Well generally property names are strings and the "dot" notation only
> works for those strings that are identifiers. So the general property
> access notation is the "bracket" notation, not the "dot" notation.
Okay.
So they are always strings, even the empty string,
and a number is converted to a string first?
var a = {};
a['8'] = 2;
a[08] = 9;
alert(a['8']); // 9
alert(a[8]); // 9
a['08'] = 2;
alert(a[8]); // 9
a['8'] = 1;
alert(a[8]); // 1
alert(a.length); // undefined [not an array]
> But that is nothing new, is it? When PHP required a group of input
> controls to be named 'foo[]' e.g.
> <input type="radio" name="foo[]" ...>
Well, I don't speak php,
why would it require that in this example?
> then you always needed the bracket notation in Javascript to access
> them, as in
> document.forms.formName.elements['foo[]'][0]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Undottability "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-24 11:34 +0100
Re: Undottability Martin Honnen <mahotrash@yahoo.de> - 2013-03-24 12:02 +0100
Re: Undottability "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-03-24 19:50 +0100
Re: Undottability Martin Honnen <mahotrash@yahoo.de> - 2013-03-26 11:59 +0100
csiph-web