Tuesday, July 24, 2012

node.js – Javascript loop reference



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..






Rating: 4 out of 5 based on 3 ratings



The post node.js – Javascript loop reference appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/node-js-javascript-loop-reference.html

No comments:

Post a Comment