I recently summed up the use of javascript, the following share to you-focus on the blog Park Old Bull lecture hall
Use of Arrays:
var arr=[10,1,66,55,100,5,2,7,1];
var arr1=[4,8,11];
Console.log (arr.push (4,8,11));//add The end element, return the length of the array
Console.log ("add element at the end:" +arr);
Console.log (arr.unshift (4,8,11));//add Header element, return array length
Console.log ("add element at the beginning:" +arr);
Console.log (arr.shift ());//delete The first element of the array, return the deleted element if the array is not empty, and return the undefined
Console.log ("delete the first element:" +arr);
Console.log (arr.pop ());//delete The last element of the array, return the deleted element if the array is not empty, and return the undefined
Console.log ("delete last element:" +arr);
Console.log (a=arr.concat (arr1));//connection Array
Console.log ("connected array" +a);
var arr=[10,1,66,55,100,5,2,7,1];
Console.log ("middle plus-after result" +arr.join ("-"));//the middle of each element plus-
Console.log ("sort:" +arr.sort ());//not A full sort, parentheses can be added value
Console.log (arr.splice (2,2, "1", "1"));//the first element represents the starting position, the second element represents the number of substituted elements, and the next two represent the substituted elements.
Console.log ("array to string" +arr.join ());
Application of Strings:?--pay attention to blog Park Lao Niu da Lecture Hall
?
var str= "Hello world";
var str1=["Lao", "Niu"];
Console.log ("returns The first subscript of the element" +str.indexof ("l"));
Console.log ("first parameter, intercept start position, second intercept length" +str.substr);
Console.log ("first parameter, intercept start position, second end position" +str.substring);
Console.log ("return character based on position" +str.charat (3));
Console.log ("the element is intercepted in the array returned to" +str.split ("l"));
Console.log ("intercept string" +str.slice ());
Console.log ("becomes lowercase" +str.tolowercase ());
Console.log ("becomes uppercase" +str.touppercase ());
Basic JavaScript Usage--blog Park Old Bull Lecture Hall