So, I'm working on a JavaScript project. I building a self driving car in JavaScript.
I've built a random roads map generator class from which I need to return an Array of Arrays of Arrays of Arrays.
Array [Contains all Grid cells of Map] of Arrays [each is a cell containing borders Top, Bottom, Left, Right Border] of Arrays (each is a border containing xy to xy point of border line) of Arrays [each contains x, y point].
Why am I doing this? It is because each border line will be passed to each sensor of a car of detecting borders by the car.
[Image of Car sensor & road border Lines] (https://i.stack.imgur.com/b6EdD.png).
So the problem is that I return whole Array from a road map generation class function as
availableBorders()
{
console.log(typeof(this.allborders)); // object
return this.allborders;
}
I receive this Array in Main Method as
const newRoadMap = new Maze(RoadMapSize, rowsColumns, rowsColumns); //Instantiate Map Object
newRoadMap.setup(); // Set the Grid for Map Generation
let xx = (newRoadMap.availableBorders());
When i print xx on console it gives
console.log(" all border ",xx);
Image of Result of Console.log mentioned above
Okay!
But when I need specific value it says undefined.
console.log(xx[0]); //undefined
console.log(xx[0][0]); //undefined
console.log(xx[0][0][0]); //undefined
console.log(xx[0][0][0][0]); //undefined
console.log(typeof(xx)); //object
I've been reading post upon post but can't find a solution to this problem. How can i access data in this array of arrays of arrays of arrays?
I've read so many post.
In my use case i am not allowed to use any other library.
Someone mention call .toObject onto the array & then use it.
.toObject does'not exist.