수학에서 자주 사용하는 상수와 함수들을 미리 구현해놓은 자바스크립트 표준 내장 객체
min() : 인수로 전달 받은 값 중에서 가장 작은 수를 리턴함.
인수가 전달되지 않으면 Infinity를 리턴하고 비교할 수 없는 값이 포함되어 있으면 NaN을 리턴함
max() : 인수로 전달 받은 값 중에서 가장 큰 수를 리턴함.
인수가 전달되지 않으면 -Infinity를 리턴하고 비교할 수 없는 값이 포함되어 있으면 NaN을 리턴함
round() : 인수로 전달 받은 값을 소수점 첫번째 자리에서 반올림하여 그 결과를 리턴함.
floor() : 인수로 전달 받은 값과 같거나 작은 수 중에서 가장 큰 정수를 리턴함.
ceil() : 인수로 전달 받은 값과 같거나 큰 수 중에서 가장 작은 정수를 리턴함.
random() : 0보다 크거나 같고 1보다 작은 무작위의 소수를 리턴함.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Math 객체</title>
</head>
<body>
<h2>Math 객체</h2>
<script>
'use strict';
console.log(Math.min());
console.log(Math.min(1, 10, -10, 1000, 0));
console.log(Math.min(1, 10, -10, "-1000", 0));
console.log(Math.min(1, 10, -10, "문자열", 0));
console.log(Math.max());
console.log(Math.round(10.49)); // 10
console.log(Math.round(10.5)); // 11
console.log(Math.round(-10.5)); // -10
console.log(Math.round(-10.51)); // -11
console.log(Math.floor(10.49)); // 10
console.log(Math.floor(10.5)); // 10
console.log(Math.floor(-10.5)); // -11
console.log(Math.floor(-10.51)); // -11
console.log(Math.ceil(10.49)); // 11
console.log(Math.ceil(10.5)); // 11
console.log(Math.ceil(-10.5)); // -10
console.log(Math.ceil(-10.51)); // -10
const rm = Math.random(); // 0 ~ 0.99999999..
console.log(rm); // 0.12377488104318535
let lotto = Math.random(); // 0 ~ 0.99999
// 1 ~ 45
lotto = Math.floor(lotto * 45) + 1
console.log(`로또 번호 : ${lotto}`);
</script>
</body>
</html>