Understanding the Use of Arrays

Array
Arrays are one variable that can contain a lot of independent data. The stored data is given a specific index or uses sequence numbers starting from 0. This index can later be used to access data stored in the array.

Types of Arrays
  • Monodimensional / one dimensional array
  • Multidimensional array
  • Associative Array
Array Making
There are several ways that can be used to create arrays in Javascript
Example:

Accessing data in Arrays

Accessing data or elements in the table can be done by writing the table name followed by square brackets containing the indexs of the elements.
Save data in Arrays
Storage of data in an array is done by writing the name of the array, followed by the name of the index in parentheses, and entering the value of the data, such as the following example.
Example array function
  1. Push Array: Push is used to add data to the end of an array
  2. Array Pop: Pop is used to delete data at the end of an array
  3. Array Length: Used to calculate the number of elements
  4. Array Number: To display the nth element
Experiment, make the web page as follows.
Save the file as array.html
Make a web page as follows.
Save the file as array_push.html
Make a web page as follows.
Save as array_pop.html
Make a web page as follows.
Save the file with the name array_length.html

0 Response to "Understanding the Use of Arrays"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel