1, calculated from 1 to 100 and value.
For loop
<script type= "Text/javascript" >
var sum=0;
for (var i= 0;i<=100;i++) {
Sum+=i;
}
Console.log (sum);
</script>
While loop
var x=1;
var sum=0;
while (x<=100) {
Sum+=x;
x + +;
}
Console.log (sum);
Do and loop
var x=1;
var sum=0;
do {
Sum+=x;
x + +;
}while (x<=100) {
Console.log (sum);
}
2, the use of strings
<script type= "Text/javascript" >
var str= "Hello, my name is Fanfan";
var a= "abcdef";
var a= "Ghjkn";
Console.log (Str.charat (3));//return string
Console.log (Str.indexof ("Van", 0));//Retrieving strings
Console.log (Str.lastindexof ("I"));//Returns the position of the substring of the object that appears
Console.log (str.substring (0, 5));//returns 0--5 with No 5 string
Console.log (A.touppercase ());//Turn capital
Console.log (A.tolowercase ());//Turn lowercase
Console.log (Str.slice (0, 6));//Returns a string within the specified range
Console.log (Str.split ([Str[0, 4]]));//Split string
</script>
3, array manipulation
<script type= "Text/javascript" >
<!--declaration array--
var arr = new Array ();
Arr[0] = 1;
ARR[1] = "1";
ARR[2] = null;
Console.log (arr);
Console.log (arr.length);
Declaring Array method two
var arr = [];
Arr[0] = 1;
ARR[1] = "1";
ARR[2] = null;
Console.log (arr);
Console.log (arr.length);
Declaring array method Three, the simplest and most effective
var arr=[1,2,null];
Console.log (arr);
Console.log (arr.length);
Removing the array, deleting the
var arr=[1,2,3,4,5];
Arr.shift ();//removal of the first
Arr.pop ();//Delete Last
Arr.unshift ("Hello", "thank You");//Increase in the head
Arr.splice (1, 1, 9);//Where to start, replace
Arr.reverse ();//reverse order
Console.log (Arr.slice (0,3));//Returns a new array
Console.log (arr);
Console.log (arr.length);
</script>
Cyclic addition and Array methods