Java learning 09

 

1. Define an array format and assign access the array: the array element name = array [index value]
2. Create an array object
3. Create an empty array
to obtain an array of array element assigned an assignment but defined length access array element

Two-dimensional array defined var arr = [[ "a" , "b", "c"], [1,2,3], [ "e", "f", "g"]];
access a two-dimensional array length Alert (arr.length);
Alert (2. 5%); modulo
a ++ first assignment, since increasing a
++ a increases from a first, after the assignment
== simple content determination indicates
=== rigorous judgment indicates
&&, and sides all true by
\\, or at least one side is ture by both sides
! , The opposite result of taking non
ternary operator
format: Expression? Value 1: 2 value
Operation: If the expression evaluates to true, the result is a value of 1
if the expression is false then the result is a value 2
IF, Switch, the while statement

 

 

Code

<Script type = "text / JavaScript">
/ * the array definition and assignment. 1 * /.
var ARR = [1, 2,3,5, "A", "B", 1.2];
/ * access the array format: Array element = array name [index value] * /
var STR = ARR [. 4];
Alert (STR);

. / * 2 creates an array of objects * /
var arr2 is = new new the array ();
/ *. 3 empty array * /.
var = arr2 is // []
/ * assign to the array elements * /
arr2 is [0] =. 1;
arr2 is [. 1] = "V";
arr2 is [2] = "A";
Alert (arr2 is [2]);
/ * Get array length * /
var len = arr2.length;
Alert (len);
/ * assign access array element as defined but * /
Alert (arr2 is [. 3]);
</ Script>

 

<Script type = "text / JavaScript">
/ * define a two-dimensional array * /
var ARR = [[ "A", "B", "C"], [l, 2,3], [ "E", " F "," G "]];
/ * access the two-dimensional array * /
Alert (ARR [. 1] [. 1]);
/ * length two-dimensional array access * /
Alert (arr.length);
</ Script>

<Script type = "text / JavaScript">
/ * Alert (2. 5%); modulo * /
/ * when ++ or - when the characteristics do not participate in the assignment or calculation * /
var. 1 = A
+ A;
Alert (a);
/ * when ++ or - participation or assignment calculation * /
/ * a + first assignment, since the increase in a * /
/ * ++ a increases from a first, after the assignment * /
var. 1 = a;
B = A + 1'd ++ var;
Alert (A);
Alert (B);

</script>

 

<Script type = "text / JavaScript">
/ == * represents simple content determined * /
/ * represents a rigorous determination === * /
var A;
var B = null;
Alert (A == B);
Alert (A = B ==);
/ * &&, is true with all sides by * /
/ * \\, at least one side or both sides by ture is * /
/ *! , Noncored counterproductive * /
</ Script>

 

<script type = "text / javascript ">
determines whether the number is a three digit
var Number = 50;
IF (Number> = 100 && Number <1000) {
Alert ( "This is a three-digit number")
} the else {
Alert ( " this is not a three-digit number ")
}
is determined a number is even or odd
var NUM = 10;
IF (NUM% 2 ==. 1) {
Alert (" it is an odd number ")
} the else IF (NUM == 0) {
Alert ( "this non-singular uneven number")
} the else {
Alert ( "it is an even number")
}
var NUM = prompt ( "Please output a number:");
IF (NUM> = 80 && NUM <= 100) {
Alert ( "you well worth learning of praise ");!
} the else IF (NUM <80 && NUM> = 60) {
Alert (" Come to continue their efforts! ");
} the else IF (NUM <60 && NUM> = 50) {
Alert (" almost point work harder ")!;
IF the else} (NUM> = 0 && NUM <50) {
Alert ( "hard efforts must not be lazy!");
} the else {
Alert ( "you entered is incorrect, please re-enter!")
}
</script>

 

 

<Script type = "text / JavaScript">
/ * user to input determination of the week 1-7 * /
var NUM = prompt ( "Please enter a number between 1-7:");
NUM = the parseInt (NUM);
Switch (NUM) {
Case. 1:
Alert ( "Monday");
BREAK;
Case 2:
Alert ( "Tuesday");
BREAK;
Case. 3:
Alert ( "Wednesday");
BREAK;
Case. 4:
Alert ( "Thursday" );
BREAK;
Case 5:
Alert ( "Friday");
BREAK;
Case 6:
Alert ( "Saturday");
BREAK;
Case 7:
Alert ( "Sunday");
BREAK;
default:
Alert ( "your entered incorrectly, please re-enter ");
BREAK;
}

</ Script>

 

 

<Script type = "text / JavaScript">
/ * print cycle * 1-10 /
var = I. 1;
the while (I <= 10) {
Alert (I);
I ++;
}
/ * loop through the array * /
var ARR = [ 1,6,2,7,8,3,9];
var I = 0;
the while (I <arr.length) {
Alert (ARR [I ++]);
}
/ * print cycle * 1-4 /
var I = . 1;
do {
Alert (I)
I ++;
} the while (I <=. 4)
</ Script>

Guess you like

Origin www.cnblogs.com/axu-xxx/p/11100652.html