Js Array Operations Learning summary. For more information, see.
Shift:Delete the first entry of the original array and return the value of the deleted element. If the array is empty, return undefined.
Var a = [1, 2, 3, 4, 5];
Var B = a. shift ();
Result a: [2, 3, 4, 5] B: 1
Unshift: add the parameter to the beginning of the original array and return the length of the array.Var a = [1, 2, 3, 4, 5];Var B = a. unshift (-2,-1 );
Result a: [-2,-,] B: 7
Note: In IE6.0, the test return value is alway
In FIREBUG, if an object has both the length attribute and the splice method, It will be displayed as an array by firebug.
The Code is as follows:
Var obj = {length: 0, splice: function (){}}Console. log (obj)
Guess what is printed on it?
That's right. The output looks like an empty array...
In FIREBUG, if an object has both the length attribute and the splice
How can I splice html code in php, call js methods in href, and pass parameters? The code above {code...} does not work. How can I splice it? How can I splice html code in php, call js methods in href, and pass parameters?
$ LinkPage. ="". $ Page ."";
The above Code does not work. How can we splice it?
Reply conte
= [1, 2, 3, 4, 5]; var B =. unshift (-2,-1); // A: [-2,-,] B: 7 Note: In ie6.0, the returned value is always undefined, test return value in ff2.0 Is 7, so the return value of this method is not reliable. You need to use splice instead of this method when returning the value. Pop: Delete the last entry of the original array and return the value of the deleted element. If the array is empty, return undefined var A = [1, 2, 3, 4, 5]; var B =. pop (); /
Shift: Delete the first entry of the original array and return the value of the deleted element. If the array is empty, undefined is returned.VaR A = [1, 2, 3, 4, 5];VaR B = A. Shift (); // A: [2, 3, 4, 5] B: 1Unshift: add the parameter to the beginning of the original array and return the length of the array.VaR A = [1, 2, 3, 4, 5];VaR B = A. unshift (-2,-1); // A: [-2,-,] B: 7Note: In ie6.0, the test return value is always undefined, and in ff2.0, the test return value is 7. Therefore, the ret
1. shift: Delete the first entry of the original array and return the value of the deleted element. If the array is empty, undefined is returned.
Var a = [1, 2, 3, 4, 5];
Var B = a. shift (); // a: [2, 3, 4, 5] B: 1
2. unshift: add the parameter to the beginning of the original array and return the length of the array.Var a = [1, 2, 3, 4, 5];
Var B = a. unshift (-2,-1); // a: [-2,-,] B: 7
Note: In IE6.0, the test return value is always undefined, and in FF2.0, the test return value is 7. There
, return undefined var a = [, 5]; var B =. shift (); // a: [2, 3, 4, 5] B: 1 unshift: add the parameter to the beginning of the original array, and return the array length var a = [1, 2, 3, 4, 5]; var B =. unshift (-2,-1); // a: [-2,-,] B: 7 Note: In IE6.0, the returned value is always undefined, the test return value in FF2.0 is 7. Therefore, the return value of this method is not reliable and must be replaced by splice when the return value is used.
Three methods for deleting arrays by using explain script1. Use shift () methodShift: Delete the first entry of the original array and return the value of the deleted element. If the array is empty, undefined is returned.VaR chaomao = [1, 2, 3, 4, 5]VaR chaomao. Shift () // get 1Alert (chaomao) // [2, 3, 4, 5]
2. Use the POP () methodPop: Delete the last entry of the original array and return the value of the deleted element. If the array is empty, undefined is returned.VaR chaomao = [1, 2, 3,
Shift: Delete the first entry of the original array and return the value of the deleted element. If the array is empty, undefined is returned.Var a = [1, 2, 3, 4, 5];Var B = a. shift (); // a: [2, 3, 4, 5] B: 1
Unshift: add the parameter to the beginning of the original array and return the length of the array.Var a = [1, 2, 3, 4, 5];Var B = a. unshift (-2,-1); // a: [-2,-,] B: 7Note: In IE6.0, the test return value is always undefined, and in FF2.0, the test return value is 7. Therefore, the re
and returned "undefined ")Java codeCheckboxlist. unshift ("aaaa", "bbbb ");
2.3 pop () removes an element at the end of the array and returns the element.Code:Java codeCheckboxlist. pop ();
2.3 shift () removes an element starting with an array and returns the elementCode:Java codeCheckboxlist. shift ()
2.4 splice () insert (replace) or remove multiple elementsRemoval example:Splice (delindex, delcount );Delindex: the position where the removal start
. write (box); // output 0, 1, 5, 10, 15
(5) Operation Method
JS provides many methods for operations on elements already included in the array. The concat () method can create a new array based on the current array. Slice () Party
You can obtain the specified region element based on the current array and create a new array. The splice () method is mainly used to insert elements into the middle of an array.
A
Var box = [1, 2, 3, 4, 5]; var box1 =
1. shift: Delete the first entry of the original array and return the value of the deleted element. If the array is empty, undefined is returned. Var a = [1, 2, 3, 4, 5];Var B = a. shift (); // a: [2, 3, 4, 5] B: 12. unshift: add the parameter to the beginning of the original array and return the length of the array.Var a = [1, 2, 3, 4, 5];Var B = a. unshift (-2,-1); // a: [-2,-,] B: 7Note: In IE6.0, the test return value is always undefined, and in FF2.0, the test return value is 7. Therefore,
JS deletes an element method in an array. js deletes an array element.
Deletes an element specified by an array.
First, you can define a function for the JS array object to find the location of the specified Element in the array, that is, the index. The code is:
Array.prototype.indexOf = function(val) { for (var i = 0; i
Then, use the built-in functions of the js array to delete this element by obtaining the index of this element:
Code:
Array.prototype.remove = function(val) { var index = this.
array.VaR A = [1, 2, 3, 4, 5];VaR B = A. unshift (-2,-1); // A: [-2,-,] B: 7Note: In ie6.0, the test return value is always undefined, and in ff2.0, the test return value is 7. Therefore, the return value of this method is unreliable. You need to use splice instead of this method when returning the value.
Pop: Delete the last entry of the original array and return the value of the deleted element. If the array is empty, undefined is returned.VaR A =
() and pop () shift () and Unshift ( ) sort () reverse () concat () Slice () splice () indexOf () and LastIndexOf () (ES5 New) ForEach () (ES5 New) map () (ES5 Add) filter () (ES5 New) every () (ES5 New) Some () (ES5 new) reduce () and Reduceright () (ES5 New) New method browser support for ES5: Opera11+Firefox3.6+Safari5+Chrome8+Internet Explorer+for supported browser versions, this can be done through the array prototype extension. The basic functi
ultimately determine whether a value is an array, regardless of the global execution environment in which it was created.
Array method
The following is an introduction to the methods of arrays, which have array prototypes and methods inherited from object objects, where we only introduce the prototype methods of arrays, and the array prototyping methods are mainly as follows:
Join ()Push () and pop ()Shift () and unshift ()Sort ()Reverse ()Concat ()Slice ()
);//[1, 2, 3, 4]
Console.log (a.length);//4
Console.log (A.pop (a));//4
Console.log (a); [1, 2, 3]
Console.log (a.length);//3
Queue method
Now that the stack method is implemented, how can the first-first out queue be less, the shift method can delete the index of the smallest element of the array, and make the following element index minus one, length also minus one, so that using Shift/push can simulate the queue, Of course, there is a unshift method corresponding to the shif
happen if the same lecturer spoke at the same volume in a busy football field. The lecturer will have to increase his volume so that his voice needs to signal) the difference from the crowd's background noise) to be heard. This is ACR.
In fact, the development of application technology still needs to measure new parameters. Return Loss, expressed in dB) form, is a reflection of some signals caused by mismatch of characteristic impedance. Ripple loss is an increasingly important parameter when t
cable is considered genuine (Note: it cannot be completely guaranteed :)).
Then determine the type of the twisted pair. The wires in the twisted pair cables are paired, and each two wires is a pair and twisted. According to the U. S. Cable specification (AWG): All wires in twisted pair wires should be 4 pairs, a total of 8. However, the 10 M Ethernet standard requires only two pairs of wire transmission signals, so some of the three types of twisted pair wires are two pairs, while some are four
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.