In JavaScript : How do I define an array of booleans of a certain length without having to define manually, e.g. an array with 60 elements in it ?
var anArrayOfBooleansWith60ElementsInIt = [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false];
JavaScript is loosely typed, so you can't really do that. You can of course create a 60 element array.
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array
var a = new Array(60);
And then you could just fill it with false or something.
for (var i = 0; i < a.length; ++i) { a[i] = false; }
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