Methods for manipulating arrays (functions):
(common) push () adds a new element from the tail operation is the original array
Pop () deletes an element from the tail
Unshift () Adding elements from the beginning
Shift () removes an element from the beginning
Slice (start, end) gets some elements in the array, returns a new array, and intercepts the end subscript from the start subscript position (without containing the element where the end subscript is located)
Join (string) joins the elements in the array into strings and returns. If join () does not give arguments, separated by commas, or, if given arguments, delimited by the specified delimiter, forming a string return
Splice (start, length) starts from the array start position and deletes length elements. The direct operation is the original array
Common Splice (start, length, element 1, Element 2:) starts from the start position, replacing the corresponding length element as element 1, Element 2 ...
(common) IndexOf () returns the position of the specified element in the array at the first occurrence of 2. Search backward from the specified position, and the corresponding subscript is returned; no return-1 is found
(common) sort () array sort sorted in ascending order of ASCII corresponding values
To sort by numerical numeric size, you need to pass a function that sets the collation as the parameter score is the array to sort
Score.sort (function (x, y) {
return x-y;
});
Console.log (score);
// use Forin when you need to traverse an object
Defining objects
var dog = {
//Key (key) value pair form
Name: "Husky",
age:3,
color: "Gold"
};
For (k in dog) {
console.log (k, dog[k]);
}
Operation of the array