Objectives
- Create arrays in JavaScript
- Use arrays in JavaScript
- Create and use a multi-dimensional array in JavaScript
- Convert an array into a string
- Convert a string into an array
JavaScript also uses the array subscript notation as an option for referencing the properties of objects. In this case, the subscripts are strings. This looks and acts like what is called an associative array or a map in other languages. Technically, even though the notation and usage may look like a JavaScript array in some ways, it is not a JavaScript array.
Multidimensional arrays in JavaScript are created by having the elements of an array be arrays themselves. For example, to create a two dimensional array that looks like a Tic-tac-toe board and contains the numbers 1 through 9, do the following:
For the following code, assume myform is the id of a form on the page, and that f1 and f1 are the ids of input text elements.
For the following code, assume that a search string is being received via a get request, and that result is the id of a div element where we can place the decoded key/value information.