array: ( No length is required to store any type of data, defined)
First, the definition:
1. Array (1,3.14, "AA"): Refers to the given is (data)
2. Array (5): refers to the given (length)
3, [1,3.14, "AA"]: Use square brackets to define
Second, the attribute:
Length: Size of the exponential group
Third, the method:
Push: Append elements to the array
Four, Traverse:
1. For loop: for (Var i=0;i<attr.length;i++)
2. Foreach: For the For loop form (Var a in attr)
V. Examples:
1, enter 10 scores, to find the total, the highest, the lowest
var attr =[89,80,76,49,90,25,85,76,59,40];
Score:
var sum = 0;
for (Var i=0;i<attr.length;i++)
{
Sum + = Attr[i];
}
alert (ZF);
Highest score:
var ZG = 0;
for (Var i=0;i<attr.length;i++)
{
if (ATTR[I]>ZG)
{
ZG = Attr[i];
}
}
alert (ZG);
Minimum score:
var zd = ZG;
for (Var i=0;i<attr.length;i++)
{
if (ATTR[I]<ZD)
{
ZD = Attr[i];
}
}
alert (ZD);
2. When adding data, go to heavy
var attr = [2,5,10,16,27];
var sj = 27;
var CF = true;
for (var i=0; i<attr.length;i++)
{
if (SJ = = Attr[i])
{
CF = false;
Break
}
}
if (CF)
{
Attr.push (SJ);
alert (attr.length);
}
Else
{
Alert ("With duplicate value");
}
3. Bubble sort
4. Find data by dichotomy
Array traversal; add to weight; bubble; dichotomy;