Front-end/Vanila JS

[JS] Math 객체

탱 'ㅅ' 2024. 5. 23. 14:04

Math.E = 𝑒 ≈ 2.718

자연로그의 밑 값 e

 

Math.PI = 𝜋 ≈ 3.14159

원의 둘레와 지름의 비율

 

Math.random()

0 이상 1 미만의 부동소숫점 의사 난수를 반환

// 1부터 n 사이의 정수 난수 생성
Math.floor(Math.random() * n + 1)
Math.ceil(Math.random() * n)

// min부터 max 사이의 정수 난수 생성
Math.random() * (max - min) + min

 

 

 

 

 

[JS/알고리즘] 백준1085. 최솟값 최댓값

C++ 로 알고리즘을 처음 배워서 for문으로 구하는 방식만 알고 있었는데 아니 이게 웬 걸 우리 JS에겐 Math 라이브러리가 있었다. 4ms 시간이 단축됐다. Math.min(value1, value2, ...) Math.min() - JavaScript | MDN M

119taeyoung.tistory.com

 

'Front-end > Vanila JS' 카테고리의 다른 글

[JS] variables - var, let, const (scope, hoisting)  (0) 2024.04.29
[JS] CSS in JS  (0) 2024.04.25
[JS] Console 객체  (0) 2024.04.24
[JS] Events  (0) 2023.12.27
[JS] HTML in JS (document 객체) 📌  (0) 2023.12.21