" //document.write (Arr.sort (sortnumber)) //change the values in an arrayarr[5]="Opel"; //document.write (arr[5]) //Delete the last value in an array vara= NewArray () a[0] = "Hello"a[1] = "Aword"a[2] = "name" //document.write (A.pop ()) //9. When adding a new array to the array; and returns the new length. //doc
When it comes to table sorting, the first thing we should talk about is array sorting, Because array sorting is the basis of table sorting. JavaScript provides the sort () method for Arrays for table sorting. By default, this method will sort the arrays in Array in the order of ASCII codes,
Research on the Javascript Array Method1. The slice Method of Array. prototype. slice Method Array is usually used to extract fragments from an Array. However, it also has the ability to convert "class arrays" (such as arguments and HTMLCollection) into real arrays. 1 var no
The data type in JS:2 major categoriesPrimitive type: The data type where the value is stored locally on the variable5 kinds: Number String Boolean undefined nullNumber:8bytes round-off error and roundingString: 1byte per English character2bytes per Kanji characterOnce the content is created, it cannot be changedBoolean:true falseReference type: value does not guarantee the existence of a variable local data typeThe variable vs database in JSFiles on
An array is a unique set object in javascript. The test code is as follows:
More methods of arrays are shown in the table below:
Method
Description
FF
IE
Concat ()
Concatenate two or more arrays and return results.
1
4
Join ()
Put all elements of the array into a string. The elements are separated by the specified
object.ToString () converts the array to a string and returns the result.toLocaleString () converts the array to a local array and returns the result.ValueOf () returns the original value of the array object2. Write a method to remove the repeating elements of an arrayMetho
When an array needs to be cleared, many people use the following method:Copy codeThe Code is as follows:A = []; We know that javascript variable storage methods can be divided into reference types and direct quantities. The array belongs to the object, that is, the reference type. It references the variable pointer add
1. Array creation and initializationvar obj=new Array ();var arr=[];Can be extended to a certain length, the literal defines the array2. Stack by value Pass reference typeAn array is a reference type, not a value pass,Stack: Automatic allocation and release of the barrel, such as function parameters, local variables ad
This is a very basic problem, but we often do wrong. When an array needs to be cleared, many people use the following method: A = []; we know that the Javascript variable storage method is divided into reference type and direct quantity. The array belongs to the object, that is, the reference type. It references the va
() constructor allows dynamic creation and compilation of Javascript code during runtime. In this way, it is similar to the global function eval ().
Function () constructor parses the Function body each time it is executed and creates a new Function object. Therefore, it is very inefficient to call Function () constructor in a loop or frequently executed Function. On the contrary, function literal is not re-compiled every time.
When using Function
Class Array object is a good storage structure, but the function is too weak, in order to enjoy the pure array of what convenient method, before using can do the next conversion, usually can use the $.slice.call () method to do the conversion, but the old version of IE Htmlcollection, NodeList is not a subclass of object, and if using the [].slice.call () method
Javascript Array object toLocaleString () method, tolocalestring
Converts an array to a local string.
Syntax:ArrayObject. toLocaleString ()Returns the local string of the arrayObject.The method first calls the toLocaleString () method of each
, in determining whether the data type of 2 variables is the same (c) function internal array arguments:First, the array can only be used inside the function, to hold the actual arguments, as an item of the array, see an example below:Operating effect:Arguments.callee is a pointer to the function itself, typically used for function recursion(iv)
It would be better to create regular expressions literally. Obviously, sometimes we have to use the large-consumption creation method new Regexp (). For example, regular expressions are used in syntax highlighting and formatting, the more Patten you need, the longer the time it takes. Firefox seems to have issued a warning in 12 seconds, and IE is directly suspended. In this case, we need to use the group storage method to improve our
Program Perform
Objective: To realize storage search history by Localstrorage--combining Store.jsThe code is as follows:functionaddsearchhistory (key,value) {varOldarr =Store.get (key); if(Oldarr) { for(vari = 0; i ) { if(Oldarr[i] = = =value) {Oldarr.splice (i,1);//if the element exists in the data group, the element is deleted Break; }} oldarr.unshift (value); //add to first position againStore.set (Key,oldarr); } Else { varNEWARR
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.