How to define arrays:
Method One: Use the new operator with the array () constructor to create
var arr = new Array ();
Method Two: Create an array of the specified length, with only one integer in ()
var arr = new Array (3);
The length of the array: Arr.length, you can only count the length of a one-dimensional array.
Method Three: Add multiple array elements in parentheses (), separating each element with commas
var arr = new Array (10,20,30,40,50);
Mode four: use brackets [] to create an array
var arr = [10,20,30,40];
When you delete an array element with delete, only the content is purged, but the occupied space still exists.
Traversal of an array: for...in Loop statement
Grammar:
for (variable name in Object name)
{
Loop body Code;
}
The main loop (Traverse) all the properties of an object or all the elements in an array. It does not output the undefined element in an array.
Global variables and local variables:
Global variables: Variables defined outside the function, called global variables, can be used anywhere in a Web page, including within a function.
Local variables: Variables that can only be used within a function are called "local variables".
Note: The var keyword is omitted anywhere, and the variables defined are "global variables" (which can be used outside of the function) so, in general, do not omit the var keyword.
Assignment Value and assignment address:
Assignment value: Used to assign a basic data type (only one value) to a variable.
Reference address: Used to assign a composite data type (possibly with multiple values) to a variable. All two variables change at the same time.
Array Definition method Array traversal method global variables and local variables definition assignment value and assignment address definition