JavaScript Array. . :
var a1 = new Array();
var a2 = new Array(3);
var a3 = new Array('','','');
a1 - , .
a2 - (undefined) .
a3 - , .
, :
a3[5]='';
JavaScript :
a3[3]=4; a3[4]=5; a3[7]=false;
, , .
:
var myArray = new Array(2);
for (i=0; i<3; i++){
myArray[i] = new Array(2);
}
, .
Array
length. .
Array
concat(). . : c=a.concat(b); b a.
join(). . . . s=c.join('; ');
reverse(). .
slice(). . , . . , .
Math
Math - JavaScript , . Math, . Math , - . Math , with.
Math
Math . :
. - | ||
E | Math.E | E e, 2.718281828459045. |
LN10 | Math.LN10 | LN10 10 (ln 10), 2.302585092994046 |
LOG10E | Math.LOG10E | LOG10E e (lg e), 0.4342944819032518 |
LOG2E | Math.LOG2E | LOG2E e (log2e), 1.4426950408889634 |
PI | Math.PI | PI π ( ), 3.1415926535897932 |
SQRT1_2 | Math.SQRT1_2 | SQRT1_2 1/2, 0.7071067811865476 |
SQRT2 | Math.SQRT2 | SQRT2 2, 1.4142135623730951 |
abs | Math.abs() | : : abs |
acos | Math.acos() | : : . acos . -1 1 , 0 π. NaN. |
asin | Math.asin() | : : . asin . - 1 1 , -π/2 +π/2. NaN. |
atan | Math.atan() | : : atan . -π/2 +π/2. |
atan2 | Math.atan2(1, 2) | : 1, 2 : . atan2 1 2. -π +π (2, 1). |
ceil | Math.ceil() | : : . ceil , . |
cos | Math.cos() | : : cos . -1 +1. |
exp | Math.exp() | : : exp (e , ). 709.78, Inifinity. |
floor | Math.floor() | : : . floor , . |
log | Math.log() | : : . log . , NaN. |
max | Math.max(1, , N) | : 1, , N : . max . , -Inifinity. |
min | Math.min(1, , N) | : 1, , N . : . min . , Inifinity. |
pow | Math.pow(1, 2) | : 1, 2 . : . pow 1, 2 (12). |
random | Math.random() | : . random 0 1 . |
round | Math.round() | : . : . round . |
sin | Math.sin() | : . : . sin . -1 +1. |
sqrt | Math.sqrt() | : . : . sqrt . , NaN. |
tan | Math.tan() | : . : . tan . |
JavaScript , . , , , , . .
|
|
|
|
, . . , .
, . , , onClick, , , - onFocus.
JavaScript , , HTML- :
_="_", , .
, , , , , :
<input type="text" name="Inform" onFocus="alert(Hello World);">HTML-, , , . alert(). , , JavaScript .
, :
<a href = "http://www.ya.ru" onmouseover="alert('An onMouseOver event'); return false"> !!!</a>, HTML :
IE: Internet Explorer, F: Firefox, O: Opera, W3C:W3C | |||||
IE | F | O | |||
onabort | |||||
onblur | |||||
onchange | |||||
onclick | |||||
ondblclick | |||||
onerror | |||||
onfocus | |||||
onkeydown | |||||
onkeypress | |||||
onkeyup | |||||
onload | |||||
onmousedown | |||||
onmousemove | |||||
onmouseout | |||||
onmouseover | |||||
onmouseup | |||||
onreset | "Reset" | ||||
onresize | |||||
onselect | |||||
onsubmit | "Submit" | ||||
onunload | - |
|
|
1. ( ) alert , , , .
2. :
1,8,15 | 20 . . Peremennaya = Math.random(); |
2,9 | 10 . . . Peremennaya = Math.random(); |
3,10 | 10 . . . Peremennaya = Math.random(); |
4,11 | 20 . . , . Peremennaya = Math.random(); |
5,12 | 10 , . FALSE TRUE . |
6,13 | 10 , . . |
7,14 | 10 , . . |
3
:
1,10 | |
3,11 | |
5,12 | |
4
, - , - .
5. .
. , . . chpict " " . . src , . a1 , , . d.pmi.src=d.pm2.src . , , , . . 3 .
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Untitled Document</title>
<script language="JavaScript">
function chpict ()
{
var a1=p1.src
p1.src=p2.src
|
|
p2.src=p3.src
p3.src=a1
p1.width=200
}
</script>
</HEAD>
<BODY>
<h3> </h3>
<IMG src="r_1.gif" name=p1 width=100><br>
<IMG src="r_2.gif" name=p2 width=100>
<IMG src="r_3.gif" name=p3 width=100>
<FORM name="form1">
<input type="button" value="" onClick="chpict()">
</FORM>
</BODY>
</HTML>
, .
6.
img1-6 . 1 (img7), , .. , . .
4.
. .
- JavaScript .
- JavaScript.
- JavaScript.
- JavaScript.
- JavaScript.
- JavaScript.
- JavaScript.
- .
- Math. With.
- round. min max. floor.
- .
- .
- .
- .
- .