Skip to content Skip to sidebar Skip to footer

An Array Of Booleans In Javascript

Not so new to javascript, but the following gives an error in javascript, where as my textbook says it should work. Boolean imgDirection[] = new Boolean[60]; What's the problem?

Solution 1:

This code isn't javascript:

Boolean imgDirection[] = new Boolean[60];

If you wanted to declare a 60 element array in javascript, you could simply use this:

var imgDirection = new Array(60);

Javascript variable declarations are not typed so there is no such data declaration like Boolean imgDirection[].


Post a Comment for "An Array Of Booleans In Javascript"