473,763 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

array.["property"]

Hi all,
what does it meaning that strange sintax (look at the object :) ?

if I have i.e. array.length I can use array.["length"] and is it
IE/Firefox compatible??

Nov 21 '06
30 2947
Bart Van der Donck wrote:
Richard Cornford wrote:
>But what you are calling pollution here is precisely what
makes it inappropriate to speak of the result as an associative
array. It is an object with particular characteristics , which
may be suited to the storage of key/value pairs where the keys
are in a 'safe set' but are not suited to the general storage
of key value pairs where the keys are arbitrary.

Exactly. You can say at most that javascript's implementation of
"associativ e arrays" is not that good. This might be your
opinion and that of others, but it's still an opinion.
It is not my opinion (and I doubt that many others hod it). It is
ridiculous to speak of a javascript object as an associative array that
is "not that good". A javascript object is a very good javascript
object, and it is that in every implementation.
That doesn't touch the core of the discussion. One can say
that is good or bad weather, but it remains weather.
You are the one proposing labelling javascript objects as good or bad.

Consider an alternative analogy; suppose you have sizeable section of
tree trunk and someone carves a figurative sculpture out of it. Do you
know describe the result as a bad section of tree trunk because it is
now not practical to manufacture floorboards from it? The sculpture
certainly is not a good section of tree trunk, but that is not the
criteria that is applicable.

In the implementation language the object employed for the javascript
object may be an associative array (or a hash table, or a list, or
whatever facilitates what is necessary for a javascript object) but once
that underlying object has been used to manufacture a javascript object
a series of irreversible changes in the object have transformed it into
something that no longer has the qualities of an associative array.
Specifically; it no longer has the quality that all possible (therefor
arbitrary) keys are treated equally. The end result very simply is not
an associative array (good, bad or otherwise).

>The issue with the name "associativ e array" is that it brings
with it a baggage of expectations from language where associative
arrays are available. Those other associative arrays are general,
and so the expectation introduced is that the javascript object
will be general, but it just isn't.

You can not come from language X and then expect
"associativ e arrays" to work the same in language Y.
Should not, but you certainly can. A fact that a very long succession of
questions asked in this group stand testimony to.
It would be a wrong and dangerous attitude for
a programmer to have such expectations.
Yes it is a mistake, but it is not a mistake that will be discouraged by
speaking of an object that has very specific qualities of its own as an
"associativ e array".

Richard.
Nov 27 '06 #21
Matt Kruse wrote:
Richard Cornford wrote:
>Being general is what an
associative array is expected to do. Otherwise where would
it be possible to draw a line between an object in which it
as possible to store only one key/value pair using just a
single key (something that hardly anyone would regard an
associative array) and an associative array?

An associative array can have its keys be unknown until runtime.
An object (in the java sense) cannot.
Not true; java.lang.refle ct - allows the assigning of values to object
properties without the need to know the names until runtime.
Therefore, to be an associative array, the method must allow
the keys to be uknown until runtime.
Unknown until runtime implies that the keys be arbitrary. However,
insisting that an associative array be capable of handing all arbitrary
keys equally excludes the Java objects in question (and the javascript
object), while insisting on the keys being unknown until runtime does
not exclude those Java objects.
>The issue with the name "associativ e array" is that it brings
with it a baggage of expectations from language where
associative arrays are available.

The "baggage" is not consistent between people, since there is
no one definition of "associativ e array".
It doesn't matter if there expectations are not consistent if it is
extremely rare that they are helpful to them when trying to understand
javascript objects.
>Those other associative arrays are general, and so the
expectation introduced is that the javascript object will be
general, but it just isn't.

You are deciding what others' expectations are, but I don't
think that everyone shares the same expectations.
I don't think they share the same expectations, but I have observed how
expectations relating to associative arrays have stood in the way of
people understanding what a javascript object is. Virtually any
expectation can do that.

Richard.
Nov 27 '06 #22
Richard Cornford said the following on 11/27/2006 6:36 PM:

<snip>
Specifically; it no longer has the quality that all possible (therefor
arbitrary) keys are treated equally. The end result very simply is not
an associative array (good, bad or otherwise).
Can you quote a reference that says an Associative Array has to be able
to have arbitrary keys?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 27 '06 #23
"Randy Webb" wrote:
Richard Cornford said the following on 11/27/2006 6:36 PM:
>Specifically ; it no longer has the quality that all possible
(therefor arbitrary) keys are treated equally. The end result
very simply is not an associative array (good, bad or otherwise).

Can you quote a reference that says an Associative Array has
to be able to have arbitrary keys?
Why do I need to? Can you cite an example of something that
unambiguously is an associative array that would treat keys of the same
type differently depending on the value of those keys?

Richard.
Nov 28 '06 #24
Richard Cornford said the following on 11/27/2006 8:21 PM:
"Randy Webb" wrote:
>Richard Cornford said the following on 11/27/2006 6:36 PM:
>>Specificall y; it no longer has the quality that all possible
(therefor arbitrary) keys are treated equally. The end result
very simply is not an associative array (good, bad or otherwise).
Can you quote a reference that says an Associative Array has
to be able to have arbitrary keys?

Why do I need to?
Because it would lend credence to your belief of what one is. But I
didn't expect you to quote a reference.
Can you cite an example of something that unambiguously is an
associative array that would treat keys of the same type differently
depending on the value of those keys?
I am not going to disprove your argument, I asked you to back it up and
you wouldn't. That alone speaks in and of itself Richard.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Nov 28 '06 #25
Richard Cornford wrote:
Matt Kruse wrote:
>An associative array can have its keys be unknown until runtime.
An object (in the java sense) cannot.
Not true; java.lang.refle ct - allows the assigning of values to object
properties without the need to know the names until runtime.
"Unknown" was perhaps not the best word for me to choose, if you choose to
be obtuse about it.
How about "An associative array can have its keys be determined and defined
at runtime"?
A Java object cannot have its properties defined at runtime. Reflection has
nothing to do with it.
Unknown until runtime implies that the keys be arbitrary.
No, it does not. That is just a leap of logic used to support your position.
However,
insisting that an associative array be capable of handing all
arbitrary keys
You are the only one insisting this. Once you give up on this point, things
will be easier for you.
I have observed
how expectations relating to associative arrays have stood in the way
of people understanding what a javascript object is.
That's a whole different argument. Certainly, if your goal is to understand
javascript objects, then calling them associative arrays is misleading. But
if your goal is to implement a simple associative array, insisting that
javascript does not have an AA is misleading as well.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 28 '06 #26
Richard Cornford wrote:
"Randy Webb" wrote:
>Can you quote a reference that says an Associative Array has
to be able to have arbitrary keys?
Why do I need to? Can you cite an example of something that
unambiguously is an associative array ...
Circular logic, no?

There is no way to cite an example of something that is "unambiguou sly" an
associative array, because no definition or requirements exist. And citing
an example that doesn't meet your criteria would certainly make it ambiguous
in your opinion.

I believe that a javascript object is unambiguously an associative array.
Therefore, that's my example.

The fact is, you can look around the web and in programming books all you
want and you won't find many definitions of an associative array that are as
restrictive as yours. Certainly there are many that would include the
javascript Object. So if myself and others are wrong in your eyes, we're
definitely not alone. ;)

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Nov 28 '06 #27
Richard Cornford wrote:
[...] Can you cite an example of something that unambiguously
is an associative array that would treat keys of the same type
differently depending on the value of those keys?
Sure.

#!/usr/bin/perl
use strict;
use warnings;

$ENV{"aKey"} = "aValue"; # (like js' ENV["aKey"] = "aValue")
print "(1) " . $ENV{"aKey"} . "\n";
print "(2) " . $ENV{"SYSTEMROO T"} . "\n";

$INC{"aSecondKe y"} = "aSecondVal ue";
print "(3) " . $INC{"aSecondKe y"} . "\n";
print "(4) " . $INC{"strict.pm "} . "\n";

It says:

(1) aValue
(2) C:\WINDOWS
(3) aSecondValue
(4) c:/Perl/lib/strict.pm

I know Perl is not a fair game here, but this is what's going on:
hashes (=associative arrays) %INC, %ENV and %SIG hold special
pre-defined values for certain keys. Other keys are free to be filled
by the programmer.

Does this mean that there are no associative arrays in Perl ? Not at
all. It means that a Perl programmer must be aware of how associative
arrays work in Perl, and that some keys are not available for those
hashes.

Also, Perl hashes know other particularities : no sorting possibilities,
multi-dimensional hashes, (de)referencing to other vars in hash values,
additional forbidden keys from modules, etc.

--
Bart

Nov 28 '06 #28
In article <ek************ *******@news.de mon.co.uk>, Richard Cornford
<Ri*****@litote s.demon.co.ukwr ites

<snip>
>In the implementation language the object employed for the javascript
object may be an associative array (or a hash table, or a list, or
whatever facilitates what is necessary for a javascript object)
Let's be a bit technical here. 'Associative Array' is an abstract data
type that can be implemented in any way that works.

A 'Hash Table' is a programming construct that could be used in
implementing an associative array. So is a linked list; so is an
ordinary array; so are a variety of tree structures; so is a database if
one is handy (using AJAX perhaps ?). There is evidence that linked lists
are used in javascript objects.

>but once
that underlying object has been used to manufacture a javascript object
a series of irreversible changes in the object have transformed it into
something that no longer has the qualities of an associative array.
Specifically ; it no longer has the quality that all possible (therefor
arbitrary) keys are treated equally. The end result very simply is not
an associative array (good, bad or otherwise).
<snip>

Very true. But I still say that
"There are NO associative arrays in javascript"
needs a few extra words to distinguish between the internals of
javascript and the facilities that are available to programmers.
John
--
John Harris
Nov 28 '06 #29
Bart Van der Donck wrote:
Richard Cornford wrote:
>[...] Can you cite an example of something that unambiguously
is an associative array that would treat keys of the same type
differently depending on the value of those keys?

Sure.

#!/usr/bin/perl
use strict;
use warnings;

$ENV{"aKey"} = "aValue"; # (like js' ENV["aKey"] = "aValue")
print "(1) " . $ENV{"aKey"} . "\n";
print "(2) " . $ENV{"SYSTEMROO T"} . "\n";

$INC{"aSecondKe y"} = "aSecondVal ue";
print "(3) " . $INC{"aSecondKe y"} . "\n";
print "(4) " . $INC{"strict.pm "} . "\n";

It says:

(1) aValue
(2) C:\WINDOWS
(3) aSecondValue
(4) c:/Perl/lib/strict.pm
If I am reading this correctly we can see two assignments using string
keys which appear to both be successful, and four retrievals using
string keys, which all appear to be equally successful. This does not
demonstrate any treating of keys differently based upon the value of the
key.

I suppose you are suggesting that the second of each pair of retrievals
is treating the keys differently as they have (supposedly) not been
assigned. But that is not reasonable as your code does not show the
instantiation of the objects, or the intervening treatments of them.

What is really needed is a demonstration that writing to a 'significant'
key can fail to assign a value (or that the value will be modified in
the process).
I know Perl is not a fair game here, but this is what's going on:
hashes (=associative arrays) %INC, %ENV and %SIG hold special
pre-defined values for certain keys.
These 'associative arrays' are part of the execution environment, aren't
they? That may be used to argue that they are no longer associative
arrays, but more interfaces to the environment. But I would be more
interested in seeing them reject/modify an assignment before rejecting
the claim that they are associative arrays. As it is I don't see any
evidence of them treating keys differently depending on the actual value
of the key, only evidence that some key/value pairs have been assigned
prior to the object being exposed. And as a result these are not exempts
of associative arrays that would treat keys of the same type differently
depending on the value of those keys.
Other keys are free to be filled
by the programmer.
But can the programmer assign to the system defined keys (without
modification of the value or side effects)?
Does this mean that there are no associative arrays in
Perl ? Not at all.
I have not seen that these objects are unambiguously associative arrays,
though the code you posted does not contradict that, but even if they
were not that could not be extended to saying that Perl had no
associative arrays. But javascript only has one object type, either that
object is an associative array or javascript has no associative arrays,
it is that black and white.
It means that a Perl programmer must be aware of how
associative arrays work in Perl,
Surely it means that Pearl programmers have to be aware that these
particular associative arrays are partly pre-populated with significant
keys?
and that some keys are not available for those
hashes.
Yes, does it have any implications for when they create a new hash from
scratch?
Also, Perl hashes know other particularities : no sorting
possibilities, multi-dimensional hashes, (de)referencing
to other vars in hash values,
None of which help the decision either way.
additional forbidden keys from modules, etc.
But that may be very significant. Can you say more? Or does this only
apply to the special pre-populated hashes you started with?

Richard.
Nov 30 '06 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1678
by: Gary | last post by:
Hi, In the program below, C = A+B, and the aim is to delay the calculation of C until the user asks for C. The boolean mUTD (UpToDate) is used indicate when Calc() must be run to make the C = A+B calculation before C is returned to user. When the Driver program at bottom is run, the behavior is very strange, the debug statement "in Calc" gets printed several times on entry to the constructor, and then again several times when T.A = 1...
8
14274
by: Don Wash | last post by:
Hi There! I'm using VB.NET to create a TreeView application and unfortunately I could not find "Key" property in Node items of the TreeView. We used to have "Key" property in TreeView node object in VB6. What is the equivalent of "Key" property of TreeView node in VB.NET? Has the property name "Key" has been changed to something else? Or VB.NET does not support the "Key" property anymore? If so what are the alternatives?
3
2266
by: jbeteta | last post by:
Hello, I have a problem declaring variables. I need to create an object oRpte as ReportClass on WebForm1.aspx and be able to use its value on WebForm2.aspx. For declaring the property oRpte() on WebForm1.aspx, I use "Public Property" and I declare variable _oRpte as Friend Shared. That's my problem. If I don't declare _oRpte as Friend Shared, I can't use WebForm1.oRpte() on other webpage. If I declare _oRpte as Friend Shared, I can use...
7
8628
by: =?Utf-8?B?YXVsZGg=?= | last post by:
hello, i'm try to research the way to open a remote machine's to collect the services and processes. i have the local data collection running but i can not figure out what MSDN or the C# help file is stating how to use "servicecollecter.machinename" to get the remote server's data. there is no samples on using framework to do this but loads of WMI. can someone share any sample / snippet on using framework with C# 2005 to get the...
0
9389
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9828
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8825
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7370
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5271
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5410
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3529
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2797
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.