Hello
i lost about 4 hours debugging strange issue
my work flow was
var config = {
someKey : [
'valueA','valueB'
]
};
function anAction()
{
// some code and loops like a maze, then
async.each(config.someKey,function(configKey)
{
// another maze+asynchronous , and because off my bad luck i use configKey inside if statement and change it
});
}
so after the loop async.each change my config values like if it's call by reference
so my question if it's default behaviour in javascript to use call by reference or it's async behaviour ?
Edit
it's not related to async
please test this example
var crazy = [
{key:'value'}
];
// safe code no change
crazy.forEach(function(item)
{
item = 'new value';
});
console.log(crazy);
// bad code do change
crazy.forEach(function(item)
{
item.key = 'new value';
});
console.log(crazy);