I have code that looks something like this:
function pathfind (start,end,map)
{
this.Init = function ()
{
this.open_node = new Array();
this.open_node.push(start);
console.log(this.open_node);
this.Loop();
}
this.Loop = function ()
{
//Some code here
}
this.Init();
}
For some reason when I push "start" to this.open_node and I log its value, I get "undefined". However, after some bug testing I realized that commenting out this.Loop(); in this.Init causes push to function properly and console.log to return [start] as it should. Can anyone explain why on earth this behavior would occur?
EDIT: I'm calling
pathfind({x:2,y:2},{x:24,y:24},parsemap(25,25));
After further research I found that console.log doesn't execute immediately in Chrome. Hence the outdated reports.