Notice
Recent Posts
Recent Comments
Link
ยซ   2025/05   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

eazyseon

Math ๋ณธ๋ฌธ

๐Ÿ“’JavaScript

Math

eazyseon 2023. 3. 11. 10:01
๋ฐ˜์‘ํ˜•

Math

์ˆ˜ํ•™์ ์ธ ์ƒ์ˆ˜์™€ ํ•จ์ˆ˜๋ฅผ ์œ„ํ•œ ์†์„ฑ๊ณผ ๋ฉ”์„œ๋“œ๋ฅผ ๊ฐ€์ง„ ๋‚ด์žฅ ๊ฐ์ฒด

 

 

๋งŽ์ด ์“ฐ์ด๋Š” Math๊ฐ์ฒด์˜ ๋ฉ”์†Œ๋“œ ์•Œ์•„๋ณด๊ธฐ!

 

1. ์ ˆ๋Œ“๊ฐ’

Math.abs(-1) //1 
Math.abs(-123.3) //123.3

 

2. ์†Œ์ˆ˜์  ์ดํ•˜ ์˜ฌ๋ฆผ

Math.ceil(1.5) //2
Math.ceil(2.1) //3

 

3. ์†Œ์ˆ˜์  ์ดํ•˜ ๋‚ด๋ฆผ

Math.floor(1.5) //1
Math.floor(2.1) //2
Math.floor(-3.7)//4

 

4. ์†Œ์ˆ˜์  ์ดํ•˜ ๋ฐ˜์˜ฌ๋ฆผ

Math.round(1.5) //2
Math.round(2.1) //2

 

 

5. ์ •์ˆ˜๋งŒ ๋ฐ˜ํ™˜

Math.trunc(1.7) //1
Math.trunc(2.1) //2
Math.trunc(-3.243876) //-3

 

6. ์ตœ๋Œ“๊ฐ’ ์ฐพ๊ธฐ

Math.max(1,2,3) //3
Math.max(1.2,-100,0) //1.2

 

7. ์ตœ์†Ÿ๊ฐ’ ์ฐพ๊ธฐ

Math.min(1,2,3) //1
Math.min(1.2,-100,0) //-100

 

8. ๊ฑฐ๋“ญ์ œ๊ณฑ

Math.pow(2,3) //2*2*2 => 8
Math.pow(3,2) //3*3 => 9

 

9. ์ œ๊ณฑ๊ทผ

Math.sqrt(4) //2
Math.sqrt(9) //3

 

10. ๋žœ๋ค ํ•œ ๊ฐ’ (๊ณ„์† ๋ฐ”๋€œ!)

Math.random() //0.4344363231124728
Math.random() //0.2353242342349775

 

๋ฐ˜์‘ํ˜•

'๐Ÿ“’JavaScript' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

for in / for of  (0) 2023.03.21
์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ๋ฌธ์ž์—ด ์ž๋ฅด๊ธฐ (substr,substring,slice)  (0) 2023.02.27
lastIndexOf  (0) 2023.02.22
Set ์ƒ์„ฑ์ž  (0) 2023.02.20
์ด์ค‘์‚ผํ•ญ์—ฐ์‚ฐ์ž  (0) 2023.02.16
Comments