JS in the array operation function is still very much, today suddenly thought to sum up, is also known as the temperature of the new bar. However, will not be for each approach to a summary, but for some more commonly used to make a note. The JS
Split converts a string to an array and outputs the code:
Copy Code code as follows:
JS Delete array elements:
var arr=[' A ', ' B ', ' C '];There are two ways to delete a ' B ' in it:
1.delete method: Delete Arr[1]
Original: JS array processing function Summary1, concat () connect two or more arraysThe method does not alter the existing array, but only returns a copy of the concatenated array.For example:1 Output Result:1,2,3,4,5,11,22,332. Join ()Put all the
Array additions and deletions(last in, first out) the most recently added item was first removedpush () can take any number of arguments, add them to the end of the array, and return the modified array lengthpop () deletes the item at the end of the
JS Array definitionCollectionThere are four ways to define an arrayUsing constructors:var a = new Array ();var B = new Array (8);var c = new Array ("First", "second", "third");or array Direct volume:var d = ["First", "second", "third"];PropertyArray
PrefaceTo remove an element from a list in Java, you can use the Remove method directly.In the JS array does not have the Remove method, but in the JS array has the Splice method can achieve the same effect, in addition, you can also use other ways
Array Create an array var New Array (); var New Array (3); var New Array (' JavaScript ', ' Java ', ' PHP ');Adding an array elementArr.push (); arr[0] = ' Redis ';To delete an array element 1.delete method: Delete Arr[1]This way the array
Reference types are object, Array, Date, RegExp, Function, basic wrapper typeCreate an object instance with the new + constructor, for example: var obj = new Object ();Object typeYou can also use object literal notation to represent objects:var
1. Instrumentation array: Array.isarray (value) support Ie9+,ff4,safari5+,opera 10.5+,chrome2. Conversion method: ToString (), valueof ()3. Stack method: LIFO, Push () add the parameter to the end of the array, the POP () method removes the last
1, concat () to connect two or more arraysThis method does not change an existing array, but merely returns a copy of the connected array.For example:
Copy Code code as follows:
Output results:1,2,3,4,5,11,22,33
2. Join ()
The array type is the most commonly used reference type in ECMAScript. The data in ECMAScript is quite different from the arrays in most other languages. Although the data in ECMAScript is an ordered list of data like an array in other languages,
Javascript| Object | advanced
First, write the constructor
You can use the new operator to combine predefined constructors such as Object (), Date (), and function () to create and initialize an object. The powerful feature of object-oriented
JavaScript Slice () method
Definitions and usage
The slice () method returns the selected element from an existing array.
GrammarArrayobject.slice (start,end) parameter descriptionStart Required. Specify where to start the selection. If it is a
Array1 Number of array literals2 length3 Delete4 Listing5 Confusing places6 methods7 DimensionsArray1 Number of array literalsvar empty = []; var numbers = [ ' zero ', ' one ', ' one ', ' one ', ' three ', ' four ', ' Five ', ' six ', ' seven '
1. Array typeEach item of the ECMAScript array can hold any type of data, and the size of the array can be dynamically adjusted;(1) Creating an arrayFirst method: Array constructor var colors=new Array ();var colors1=new Array (20);var colors2=new
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
Convert 1.js to digital format in thousand-bit formatConversion of thousands of bits to numbers, e.g.: 12,345.00 to 12345.00function Rmoney (s){Return parsefloat (S.replace (/[^\d\.-]/g, ""));}To test the function code:var s= "12,345.00";Alert
In fact, after a good time of Python, I think the most I have to remember is not the python every time in writing functions or loops can be less than {} brackets such things (PS: actually also. Feel very refreshing, and began to write JS when always
VaR arr = ['A', 'B', 'C'];To delete 'B', you can use either of the following methods:
1. Delete method: delete arr [1]In this way, the length of the array remains unchanged. In this case, the ARR [1] is changed to undefined, but the index of the
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.