I wanted to know if it is possible to be able to insert multiple data into an array position using JavaScript, I mean like this:
arr[0] = [1,2,3], arr[1] = [4,5,6]
And then access one of those data, for example if I want to retrieve data "2" from arr[0], is it possible?
From already thank you very much
To put several values inside a position with Javascript is simple
I leave you to try
Here is the link so you can test and modify
In response to your question.
What you expose are arrays or arrays but in javascript they are told that they are multidimensional arrays.
This is because the array contains other arrays and those already contain what you want, in this case numbers.
I leave you a reference page: Arrays
In short, what you expose would be an array which in traditional javascript is declared as follows, initializing it as an empty array:
That is, you can store anything in that array, like so:
Now, for what you require, it would be an array that stores another array and this one that is stored contains numbers.
The problem is that if we initialize the variable as I showed at the beginning, it is not possible to add any data in a certain position, that is:
This array is going to present us with problems, since it does not have any initialized position, if you are going to have an array to which you are going to append information in a specific position, you must create the array where it reaches that position at the time of initializing it with a value for By default, you can do something like the following:
In this way, if we want to attach information through the positions, it can be done without problems, for example:
This way if you want to use that information later it will work.
Here is a working example: