JS array functions related operations

// 1, an array of splicing the concat () 
var A = [1, 2 ];
 var B = [. 3,. 4 ]; 
the console.log (a.concat (B)); // [1, 2,. 3,. 4] 

// 2, an array of flip Reverse () 
var A = [. 1, 2,. 3 ]; 
the console.log (a.reverse ()); // [. 3, 2,. 1] 

// . 3, the array is divided Slice () 
var = A [. 1, 2,. 3,. 4 ]; 
the console.log (a.slice ( . 1,. 3)); // [2,. 3] 

// . 4, an array of alternative splice () 
var A = [. 1, 2, . 3,. 4,. 5 ]; 
a.splice ( 2, 2, "A" ); 
the console.log (A); // [. 1, 2, "A",. 5]

// 5, sort the array Sort () 
var A = [2,. 1,. 3 ]; 
a.sort (); 
the console.log (A); // [. 1, 2,. 3]

Guess you like

Origin www.cnblogs.com/GetcharZp/p/12066901.html