Method call of the Array object in JavaScript, javascriptarray
Method concatfor loop and for in Loop
Join pop shift
Var arr = [,]; var arr2 = [, 4]; alert (arr. join ("-"); alert (arr. pop (); // Delete and return the last element. If the array is empty, // This method does not change the array and returns the undefined value alert (arr. shift (); // Delete and return the first element of the array
Join pop shift push unshift reverse
Var arr = [,]; var arr2 = [, 4]; var arr3 = [0]; alert (arr. join ("-"); alert (arr. pop (); // Delete and return the last element. If the array is empty, // This method does not change the array and returns the undefined value alert (arr. shift (); // Delete and return the first element of the array alert ("push:" + arr3.push )); // 5 add one or more elements to the end of the array and return the new array length alert ("unshift" + arr3.unshift (3, 2 )); // 7 add one or more elements to the beginning of the array, and return the new length of the array alert (arr3); alert (arr3.reverse (); // reverse the order of elements in the array.
Sort
var arr2=[6,8,50,9,5,4];alert(arr2.sort(sortNumber));function sortNumber(a,b){ return a-b}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.