|
JavaScript
, JavaScript.
JavaScript, MX, .
JavaScript,
, , "" ,
. .
,
, Web-,
. .
.html. ? ,
() ,
Web-..html, , .
JavaScript
.
, .
,
, ""
. ( .)
, , .
; ,
, . ,
(, , , , ),
(
).
:
b
= z / t;
z t
. , "/" ,
"=" - .
";", , , ,
; , JavaScript .
:
sum
= a1 + 2 + 3 - 20; square = * ;
a1, a2 ,
20 sum.
square.
, :
s
= ( + b) / ( - d);
, ,
. ,
:
s
= a+b/c d;
,
, d.
, , d .
, .
JavaScript :
= + 1;
.
, .
:
+= 1;
:
,
, , .
var:
var
a1, a2, 3, ,
,
. , . .
.
,
. ,
:
= 10;
s
= " ";
, (
). (, Web-, , ,
, .)
, .
, . ,
. .
, , ;
.
var
arr;
arr[0]
= 1;
arr[1]
= 2;
arr[5]
= arr[0] + arr[1];
, ;
().
, ,
, . ,
, JavaScript
.
. :
var
arr2;
2[0]
[0] = 0;
2[0][1]
= 1;
2[1]
[0] = 2;
2[1][1]
= 3;
,
. , if-else
. -
, - . ,
, if, ,
else. , if-else .
.
if
(x== 1)
f
= 2 else
f
= 12;
,
, f 2,
12.
- if-else ,
.
if
( == 1) {
f
= 2;
h
= 3; } else {
f
= 12;
h
= 14; }
, ,
. JavaScript .
"" if-eise, else.
, , cod .
if
( == 1) ( f = 2; h = 3; )
- switch-case.
if-eise.
switch
() { case 1 :
out
= "";
break;
case 2 :
out
= "";
break;
case 3 :
out
= "";
break;
default :
out
= " "; }
1, out
( case l). 2, out
( 2), . . ,
case, default, out
.
, - cod
, switch.
.
for - ( )
, . . .
- ,
, .
,
.
for .
for
(i = 1; i < 101; i++) { a = a * i; b = b + i;
}
JavaScript :
-
i , . .
;
-
1 (i =1);
-
100, . . , i
101 (i < 101);
-
(i++;
++ - ,
, , ). (
++ .)
100, b 1 100.
, JavaScript ,
. ,
- . do-while while.
do-while.
do
{
= * i + 2;
i
= ++i; } while (a < 100);
, 100. ,
,
, .
while , ,
, .
while
(a < 100) { a = a * i + 2; i = ++i; }
break , continue
, . .
(, ).
while
(a < 100) { i = ++i;
if
(i > 50) break; if (i < 5) continue; a = a * i + 2; }
, .
cod
, .
cod, ,
.
,
.
,
.
function
valuePlus2 (v) {
var
;
= v + 2;
return
; }
valuePlus2 v (.
). , ,
, "" (
).
v 2.
(return ).
? , :
h
= d + valuePlus2 (r) ;
vaiuePlus2
. , .
,
. (,
!)
function
valuePlus2(v) { return v + 2; }
. -, "".
-, , .
:
function
someFunc1() { return 2+2; }
:
function
valuePlus3(v) { return valuePlus2(v) + 1; }
JavaScript .
.
:
v= . , . .
|
|