> 
> **Possible Duplicate:**  
> 
> [javascript for loop unexpected behaviour](https://stackoverflow.com/questions/3170589/javascript-for-loop-unexpected-behaviour) 
> 
> 
> 

I'am programming in node.js and i run into a small problem what is caused by some strange pass by reference problem.

i use the following code:

```
for(j in groups){
  console.log(j, somefunction(groups[j]))
}

```

inside of the function some funky things are done with the data but afterwards i get the following as result:

```
3 data
3 data
3 data
3 data
3 data
3 data

```

instead of 

```
1 data
2 data
3 data
4 data
5 data
6 data

```

but it keeps the correct amount of result..