반응형

Math 객체(인스턴스화 없다)

 

abs(num) : 절대

pow(base, p) : base값의 p

random() : 0 ~ 1 사이의 난수

ceil(num) : 소수점 이하 올림

floor(num) : 소수점 이하 버림

round(num) : 사사오입

등등

 

math.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Math객체</title>
</head>
<body>
<pre>
<script type="text/javascript">
document.writeln(Math.abs(-15));
document.writeln(Math.max(1015));
document.writeln(Math.min(-100));
document.writeln(Math.pow(23));
document.writeln(Math.random());
 
document.writeln(Math.ceil(1.58));
document.writeln(Math.floor(1.58));
document.writeln(Math.round(1.58));
document.writeln(Math.ceil(-1.58));
document.writeln(Math.floor(-1.58));
document.writeln(Math.round(-1.58));
 
document.writeln(Math.SQRT1_2);
document.writeln(Math.SQRT2);
document.writeln(Math.sqrt(3));
 
document.writeln(Math.PI);
document.writeln(Math.cos(1));
document.writeln(Math.sin(1));
document.writeln(Math.tan(1));
document.writeln(Math.acos(1));
document.writeln(Math.asin(1));
document.writeln(Math.atan(1));
document.writeln(Math.atan2(11));
 
document.writeln(Math.E);
document.writeln(Math.LN2);
document.writeln(Math.LN10);
document.writeln(Math.LOG2E);
document.writeln(Math.LOG10E);
document.writeln(Math.log(Math.E));
document.writeln(Math.exp(1));
</script>
</pre>
</body>
</html>
cs
반응형

'교육자료 > Javascript' 카테고리의 다른 글

11. Date 내장객체  (0) 2019.05.09
10. Array 내장객체  (0) 2019.05.09
08. Number 내장객체  (0) 2019.05.09
07. String 내장객체  (0) 2019.05.09
06. 자바스크립트 내장객체  (0) 2019.05.09

+ Recent posts