Arr. arrays
New array
STR-strings
Modify Location Index--
Modified Quantity N
Item-Modified Content
"1" Array additions
1, index in turn increase
Arr.push (' item ');
Put item
2. Start adding ' item ' at the specified index
Arr.splice (index, 0, ' item ');
The second parameter must be a 0!!!
"2" removes the element from the array
1. Delete all elements from index, including index
Arr.splice (Index)
2. Delete the index element, followed by n elements, including index
Arr.splice (index, n);
"3" modifies array elements
1. Item must not be empty
Arr.splice (index, N, ' item ');
Replace the N element after index start with item, including index;
"4" finds an element in an array
1, know ' subscript ' get ' value '
var element = Arr[index];
2, know ' value ' get ' subscript '
var index = $.inarray (Element,arr);
If index =-1 indicates that ARR is not an array
"5" Array to string
1. The join () method composes all the elements of an array into a string
var arr = [A, B, C, D, E];
var str = arr.join (', ');
Use ', ' as separators;
Result: str = ' ABCDE '
"6" string to array
1. The string is cut into several strings by a character and returned as an array
var str = ' a,b,c,d,e ';
var arr = Str.splice (', ');
Result: arr = [A, B, C, D, E]
"7" Sequential sorting
1. Sort ()
var arr = [A, D, C, E, b];
var new = Arr.sort ();
Result: New = [A, B, C, D, E]
"8" random sort
1. Sort (function () {return 0.5-math.random ()})
var arr = [A, B, C, D, E];
var new = Arr.sort (function () {return 0.5-math.random ()});
Results: new = [A, D, C, E, b];
Results: new = [C, D, A, E, b];
...
JavaScript array additions and deletions change sorting string mutual transfer