earthoutreach / earth-api-utility-library

Automatically exported from code.google.com/p/earth-api-utility-library
0 stars 0 forks source link

map(p) affects any Array #24

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
looping through "associative" arrays

What is the expected output? What do you see instead?
add map(p) function to arrays only in GEX namespace?

sample script lines:
var associativeArray = new Array();
associativeArray["key"] = "value"; 
for (i in associativeArray)
{
...
}
one of the objects is "map", which was not added to array

Original issue reported on code.google.com by grzegorz...@gmail.com on 29 Jan 2010 at 2:40

GoogleCodeExporter commented 9 years ago
The common way of dealing with this (which has become standard Javascript 
practice) is by only using Objects as associative arrays, not Arrays. There are 
several reasons for this, not least of which is the behavior of for...in loops. 
See, for instance, the warning at:

https://developer.mozilla.org/en/JavaScript/Reference/Statements/for...in#sectio
n_4

With that said, adding functions to Array.prototype directly is also 
suboptimal, and map should be moved to a separate function.

Original comment by bcke...@google.com on 10 Dec 2010 at 1:18

GoogleCodeExporter commented 9 years ago

Original comment by bcke...@google.com on 10 Dec 2010 at 1:19

GoogleCodeExporter commented 9 years ago
Fixed in r65

Original comment by bcke...@google.com on 30 Dec 2010 at 3:26