var horizont, vertikal = new Array ()
for (var i=0; i < 9; i++)
{
horizont[i] = new Array ();
vertikal[i] = new Array ()
}
That's what the console told me:
TypeError: can't convert undefined to object
horizont[i] = new Array ();
(if I would erase it from the code he says the same with vertikal )
except from some other empty strings getiing born it's the beginning of my code... where is the mistake? Is it so ovious that I don't see it?
Use Object. Object. keys will return an array, which contains the property names of the object. If the length of the array is 0 , then we know that the object is empty.
Object.keys() returns an array whose elements are strings corresponding to the enumerable properties found directly upon object . The ordering of the properties is the same as that given by looping over the properties of the object manually.
The error is because you did not define horizont
as an Array. You are using a comma to separate your variable so it is undefined. It does not use the new Array()
from vertikal.
If you take your code
var horizont, vertikal = new Array ()
And write it out to use multiple variable, the error would pop out.
var horizont;
var vertikal = new Array();
You need to specify both as Arrays.
var horizont = [],
vertikal = [];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With