| built-in methods commonly used in arrays
|-push () and Pop ()
|--push () is added to the tail of the array, returning the length of the new array
var attr = [1,2,3,4,5];
var attr2 = [6,7,8,9,0];
var get = Attr.push (ATTR2);
Console.log (attr);
Console.log (get);
|--pop () is to delete the last item of the array, and to return the item that I deleted
var attr = [1,2,3,4,5];var get = Attr.pop (); Console.log (attr); Console.log (get);
|-unshift () and Shift ()
|--unshift () is added to the head of the array and returns the length of the new array
var attr = [1,2,3,4,5];var get = Attr.unshift (ten); Console.log (attr); Console.log (get);
|--shift () is to delete the first item of the array, and to return the item that I deleted
var attr = [1,2,3,4,5];var get = Attr.shift (); Console.log (attr); Console.log (get);
|-reverse () Reverses an item in an array
var attr = [1,2,3,4,5];
var get = Attr.reverse ();
Console.log (attr);
Console.log (get);
|-concat () Adds a new item at the end of the array
var attr1 = [1,2,3,4,5];
var attr2 = [6,7,8,9,0];
var get = Attr1.concat (ATTR2);
var get1 = Attr1.concat ("and", ATTR2);
var Get2 = Attr1.concat ("and" + attr2);
Console.log (get);
Console.log (GET1);
Console.log (Get2);
|-indexof () and LastIndexOf ()
|--indexof () returns the index of the first occurrence of the item found in the array, or 1 if not.
var = [4,1,66,4,23,2];var get = Attr.indexof (attr), var get = Attr.indexof (), Console.log (attr); Console.log (get);
|--laseindexof () returns the index of the first occurrence of the item found in the array, or 1 if not.
var = [4,1,66,4,23,2,66];var get = Attr.lastindexof (attr); var get = Attr.lastindexof (in); Console.log (attr); Console.log (get);
Math function Math
|-math.random random number between 0~1, 0 can be taken, 1 cannot be taken
Vvar attr = Math.random () var attr = parseint (Math.random () *100); Console.log (attr)
|-math.max, math.min maximum, minimum value
Math.max, math.min Maximum, minimum var attr = Math.max (1,6,8,2), var attr = Math.min (1,6,8,2); Console.log (attr);
|-math.pi Pi
var attr = Math.pi;console.log (attr);
| time function
|-var mydate = new Date ();
Press CTRL + C to copy the code<textarea></textarea>Press CTRL + C to copy the code
0513 Classroom 02 Arrays, mathematical functions, time functions