One: Array arrays1, Array.isarray (parameter) detection is an array,*incompatible with IE8, compatible with IE9 and above, Chrome, Firefox, etc., to be compatible with IE8, you can useObject.prototype.toString.call ([up]) = = "[Object Array]"2.
1. ECMAScript does not have a block-level scope, so variables defined inside the loop are also accessible outside the loopegvar count = 10;FPR (var i=0; ialert (i);}alert (i); 102. The function of ECMAScript can define any parameter, and the two
Summary of basic JavaScript knowledge and common methods, basic javascript knowledge
JAVASCRIPT is an indispensable part of AJAX technology. Therefore, it is most important to learn JAVASCRIPT well if you want to learn AJAX well and the popular AJAX
JavaScript Array-Array method summary (recommended), javascriptarray
The Array type in JavaScript is frequently used. The Array type also provides many methods to meet our needs. Let's summarize the following:
1. method for creating an Array
Var
New Features of JavaScript_ECMA5 array, ecmajavascript
Var arr = [1, 2, 3, 4, 5, 4, 3, 2, 1];
Method for adding a new location: indexOf lastIndexOf
When the first parameter is set, it indicates that the index position is returned by passing the
el:element The element that needs to be fetched, must be the root container element in HTML data : storage methods for data: For storing various methods The data binding literal is loaded only once {{* * * * * Msg}}data can be used for simple
vararr = [n/a];//[] is the new Array (All-in-one) syntax sugar (shorthand) varobj = {' name ': 2, ' Age ': 3};//{} is a shorthand for new Object () //var obj2 = new Object (); //obj2.name=2; //obj2.age=3; //ForEach facilitates all elements
1. Reference type 1.1 Object typeThere are two ways of creating an object type:
Use the new operator followed by the object constructor
var person =new Object ();
Notation of character volume
var person = {Name: ' Chuck '}
A few new ways to ES6 arrays:1. ForEach ()// ForEach () iterates through an array with no return value and does not change the original array var arr=[1,2,3,4]arr.foreach ((item,index,arr)={ console.log (item); // 1,2,3,4})2. Map ()// map ()
To determine whether an object is an array: instanceof, Array.isarray ()
You can use the instanceof operator for a Web page or a global scope.
if (value instanceof Array) {//To determine if value is an array}Instanceof operator It assumes that
Next is a "JavaScript array array Basics", which details all the methods of array.
The methods of all arrays are defined on Array.prototype, and the Array.prototype itself is an array.
Array.concat ()
Shallow copies the current array and attaches
var arr = [1, 2, 3, 4, 5, 4, 3, 2, 1];
New Add Position method: IndexOf LastIndexOf
When 1.1 arguments are passed, the value returns the index position (index starting from 0)
var index = Arr.indexof (4);alert (index); 3
2. When the first
Inheritance is one of the most talked-about concepts in oo language. Many OO languages support two ways of inheriting: interface inheritance and implementation inheritance. Interface inheritance inherits only the method signature, while implementing
Methods for JavaScript iterationsFilter () uses the specified function to determine whether to return an item contained in an arrayvar num = [1,2,3,4,5,6,12];Num.filter (function (item, index, array) {Return (item > 2); [3, 4, 5, 6, 12]});Map ()
1 DOCTYPE HTML>22HTMLLang= "en">33Head>44MetaCharSet= "UTF-8">55title>Test1title>66Script>7 7 8 94 9 the /*Ten the One Every,some The former is to iterate over each element in the array and execute the function, if there
Garbage Collection principle:Identify the variables that are no longer in use, and then release their memory.The most commonly used garbage collection method in JS is tag cleanup , when variables enter the environment, the variables are marked as "
Determine if an object is an array: instanceof, Array.isarray ()You can use the instanceof operator for a Web page or for a global scope.if instanceof Array) { // Determine if value is an array }instanceof Operator It assumes that there is only
Common methods for arraysArrays as an important data type, in addition to the pop, push, shift, and unshift several methods we have already mentioned, there are many practical methods that are also essential to our skills.Suppose we have a team of
var arr = [1,2,3,4];ForEachArr.foreach ((Item,index,arr) = { Console.log (item)//result is 1,2,3,4})FilterFilter filters out values in the array that do not meet the criteria, returns a new array, and does not change the value of the original
The operation string and operation array in JS are similar.Take the following array as an example:var arr = ['e'c'r ' ' o ' ]; var arrnum = [64];1, determine whether the arrayif (arr instanceof Array) { Console.log (true);} if // ECMAScript 5
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.