Adding elements to the arrayThe push () method can add one or more array items to the end of the list:var arr = [];arr.push (' A ', ' B '); Console.log (arr); [' A ', ' B '] The Unshift () method adds one or more array items to the front of the arrays:var arr = [' A ', ' B '];arr.unshift (n); Console.log (arr); [1, 2, "a", "B"]The splice () method adds an array entry to the array:var arr = [' A ', ' B ', ' C ', 1,2];arr.splice (2,0, ' d ', ' C ', ' e
]) // undefined;0405Var B = ["red", "blue", "black"];06B. length = 4; // Add a new project at the end. The default value is undefined.07Blert (a [4]) // undefined;0809Var c = ["red", "blue", "black"];10C [c. length] = "orange"; // insert a project directly at the end of the array with the value orange11C [10] = "white"; // insert a project in array position 10. If the value is white, the project at position 4-9 is undefined by default.
4. Conversion Method
All objects have the toString (), toLoc
back to forward). Figure 2 is the data organization form of list. One obvious difference from the previous two container classes is that they do not support random access. To access the items at a subscript in a table, the cycle starts from the header or the end of the table (close to the end of the table. The subscript budget operator [] is missing.
At the same time, the list still contains basic functions such as erase (), begin (), end (), insert (), push_back (), and push_front, next we wil
B = object. Therefore, go to obj [array [I]! = Array [I] |, that is, obj [B]-> obj [Object]->! = B, so it is stored
Obj [B] = B; that is, obj [Object] = B; overwrite the previous obj [Object] =;
In this case, all objects will be stored with only the last object value.
When considering objects, I will use the following method:
The Code is as follows:
For (var I = 0; I For (var j = I + 1; j If (temp [I] = temp [j]) {Temp. splice (j, 1 );J --;}}}Retur
before the array:
var arr = ['a','b'];arr.unshift(1,2);console.log(arr); // [1, 2, "a", "b"]
In addition to the two methods, you can also use the splice () method to add array items to the array:
var arr = ['a','b','c',1,2];arr.splice(2,0,'d','c','e');console.log(arr); // ["a", "b", "d", "c", "e", "c", 1, 2]
In addition to the splice () method, you can also use the concat () method to add array items
array position 10. If the value is white, the project at position 4-9 is undefined by default.
4. Conversion Method
All objects have the toString (), toLocaleString (), and valueOf () methods.
The same value is returned by calling the toString () and valueOf () Methods of the array. This will call the toString () method of each item of the array in the background to splice the final string.
1Var a = ["red", "blue", "black"];2Alert (a. toString () //
(1) = 10;
Deq1 [2] = 12;
Cout
Put_deque (deq1, "deq1 ");
// Remove an element from the front and back of the deq1 Sequence
Deq1.pop _ front ();
Deq1.pop _ back ();
Cout
Put_deque (deq1, "deq1 ");
// Clear the 2nd elements in deq1
Deq1.erase (deq1.begin () + 1 );
Cout
Put_deque (deq1, "deq1 ");
// Assign values to deq2 and display them
Deq2.assign (8, 1 );
Cout
Put_deque (deq2, "deq2 ");
}
The above demonstrates how deque performs insert and delete operati
in the array• Sort (comparefunction) method:-The parameter is a method used to compare two elements.-If the parameter is omitted, use • Slice (START, end) method:-The new array is returned, which does not affect the old array.-Contains elements starting from subscript start to subscript end-1-If end is omitted, all elements starting from the subscript start to the end are included.-If the parameter is negative, it indicates the subscripts (I .e., the subscript is n + array. Length) of the array
items before the array:
var arr = ['a','b'];arr.unshift(1,2);console.log(arr); // [1, 2, "a", "b"]
In addition to the two methods, you can also use the splice () method to add array items to the array:
var arr = ['a','b','c',1,2];arr.splice(2,0,'d','c','e');console.log(arr); // ["a", "b", "d", "c", "e", "c", 1, 2]
In addition to the splice () method, you can also use the concat () method to add array item
", "Mike", "Cynthia", "Mike", "Jennifer"];var name = "Mike";var firstpos = names.indexof (name);Console.log (Firstpos)//1var lastpos = names.lastindexof (name)Console.log (Lastpos)//32. String representation of the arrayThere are two ways to convert an array to a string: Join () and ToString (), both of which return a string containing all the elements of the array, separated by commas, and here are some examplesvar names = ["David", "Mike", "Cynthia", "Mike", "Jennifer"];var namestr = Names.joi
The factors that affect the speed of LAN Internet cafes are generally caused by some small details that some wiring personnel do not pay attention to. Therefore, pay attention to the following elements:
1. Integrated Wiring Design
During the wiring design, the switch, especially the device status of the main switch, must be designed. The popular cat5e twisted pair wires have a theoretical Transmission Interval of no more than 100 meters, and the pract
more advanced the technology, and the wider the bandwidth, the more expensive the price. Category 3 and Category 4 are almost absent in the market at present. If yes, they will not appear in category 3 or Category 4, but will be sold on Category 5 or even Category 5, this is one of the most popular fake cat-5e lines. Currently, Category 5, Category 5, or Category 6 unshielded twisted pair wires are common in LAN. The shielded cat5e twisted pair has a
As we all know, Ethernet technology is closely related to Cabling Technology. How can we develop the Gigabit Ethernet technology to support the next generation of cables, especially the six types of cables in the protocol?■ Do I need six types of cabling for a gigabit network?Currently, there is a lot of debate over whether cat6 cabling is required in the cabling industry. Remember that when three types of cabling became popular in 1992 and five types of cabling were just proposed, the cheap 10
routing design of the original cable trough Based on the cat5e or cat5e systems. The space requirement increases by 20% to 40%, which increases the construction difficulty and cost.●In the actual layout and layout process, the cables are often deformed by various external extrusion, or even by short-term external force. Because of its softness, traditional circular cables can adapt to the influence of vari
The quality of twisted pair wires may affect the overall network performance during network construction. The connection of twisted pair wires between various devices is also very exquisite and should be connected according to specifications. This article mainly introduces the standard connection method of twisted pair wires and their connection methods with various devices. The purpose is to keep everyone familiar with the rules, improve work efficiency, and ensure the normal operation of the n
The quality of twisted pair wires may affect the overall network performance during network construction. The connection of twisted pair wires between various devices is also very exquisite and should be connected according to specifications. This article mainly introduces the standard connection method of twisted pair wires and their connection methods with various devices. The purpose is to keep everyone familiar with the rules, improve work efficiency, and ensure the normal operation of the n
wires can be divided into two categories: Shielded twisted pair STP and unshielded twisted pair UTP.The shielded twisted pair wires are divided into three categories and five categories, and unshielded twisted pair wires are divided into three categories, four categories, five categories, and over five categories. The speed of the three types of twisted pair wires is 10 Mb/S, the speed of the five types of twisted pair wires can reach 100 Mb/S, and the speed of the five categories can reach mor
The quality of twisted pair wires may affect the overall network performance during network construction. The connection of twisted pair wires between various devices is also very exquisite and should be connected according to specifications. This article mainly introduces the standard connection method of twisted pair wires and their connection methods with various devices. The purpose is to keep everyone familiar with the rules, improve work efficiency, and ensure the normal operation of the n
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.