1. Array creation and initialization
var obj=new Array ();
var arr=[];
Can be extended to a certain length, the literal defines the array
2. Stack by value Pass reference type
An array is a reference type, not a value pass,
Stack: Automatic allocation and release of the barrel, such as function parameters, local variables advanced after the first-level cache
Heap: Usually released by the programmer, the system recycles the FIFO two cache at the end of the program
3. Associative arrays and indexed arrays
Associative array is a hash array, essentially JS bottom, all objects are associative arrays
so the following writing can produce running results, can run the result:2var keys=[1,2,3,4];console.log (keys["1"]);
4.example Delete array repeating unit with hash array
function f (ARR)
{
var arrc=[];
Take out the first element of Arr, put the first one in the ARRC array
ARRC[1]=ARR[0];
Iterates through an array of arr, starting with 1, extracting elements, compared to elements in ARRC
for (Var i=0;i<arr.length;i++)
{
for (Var j=0;j<arrc.length;j++)
{
if (Arrc[j]==arr[i])
break;//equal to the end of this search
Unequal is assigned to the following array,
if (j==length-1)
Arrc[arrc.length]=arr[i];
}
}
return ARRC;
}
Console.log (f ([1,2,2,1,4,5]));
Array of JavaScript notes keyword (store and release & stack & by value Reference)