There are many ways to create arrays as well.
For example
// creates the same array but with a lot less typing.
var personnel = [ // I have added a new line and then indented the nested arrays
["Name0","Age0","Address0"], // adds an array in side the first
["Name1","Age1","Address1"], // you separate all the items in the array with commas
]; //close the array.
Some people prefer to spread it out even further like
var personnel = [ // always put the first opening braket here
[
"Name0", // again indenting so it is easy to see where you are at
"Age0",
"Address0", // Javascript used not let you have a comma on the last
// element. Some people still think that should be enforced
// and some IDE will report it as an error. It is up to you.
],[ // close the first and open the second array
"Name1",
"Age1",
"Address1"
],
]; //close the array.
Then very compact all in one line.
var personnel = [["Name0","Age0","Address0"],["Name1","Age1","Address1"]];
You can insert arrays into arrays
var person0 = ["Name0","Age0","Address0"];
var person1 = ["Name1","Age1","Address1"];
var personnel = [person0, person1]; //the two arrays inserted into another array;
or
var personnel = []; // create an empty array;
personnel[0] = person0; // puts person0 array as the first item
personnel[1] = person1; // and the second array as the second item
And my personal favorite Using the String.split
method that splits a string and create an array.
"Name0,Age0,Address0".split(","); // splits the string were there are ',' commas
// creates the array ["Name0","Age0","Address0"];
The delimiter can be anything
"Name0 Age0 Address0".split(" "); //in this case a space is used
Can even split on words
"Name0 banana Age0 banana Address0".split(" banana "); // splits at space banana space
So easy creating the nested array using split. Handy if you have long lists that you want to put into arrays.
var personnel = [
"Name0,Age0,Address0".split(","),
"Name1,Age1,Address1".split(","),
];
All these techniques have created exactly the same array, and there are still many more ways to do it. There is no right or wrong way so pick what suits you and happy coding.
Improving you style not only makes it easier and quicker to write code but also make it a lot easier to find mistakes and bugs.
BTW the script tag does not need the type="text/javascript"
all you need is <script>
and a closing tag after the code </script>
the type defaults to text/javascript