I’d like to implement a 2 dim array with each cell having the same size because i need to draw it on a canvas. (e.g. 10 px)
How can I do that?
Thanks!
Code so far:
Array[0][0] = myArray;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are no two dimensional arrays in Javascript, so you have to use a jagged array, i.e. an array of arrays.
Initialise it using literal arrays:
Or the Array constructor:
An array is not a visual element, so to display it you would loop through each outer and inner array, and draw something that represents each item.