Back to feed
Renewal·서른의 생활코딩

Sample Source 3) JavaScript Basic Document Structure (Number Object)

NS
normalstory
cover image

A static object, Math, has many methods.
Let's experience the methods that control various properties of numbers through examples.





<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">




<head>


<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />




<title> Math Object </title>




<script type="text/javascript">


//<!CDATA[




/*


Because it's a static object, no instances are created.


Methods: floor(num), ceil(num), round(num), max(num1, num2), min(num1, num2), random()


*/




var num1,num2;


num1=15.2;


num2=15.7




document.write(Math.round(num1)+"<br />");


document.write(Math.floor(num1)+"<br />");


document.write(Math.ceil(num1)+"<br />");


document.write(Math.round(num2)+"<br />");


document.write(Math.floor(num2)+"<br />");


document.write(Math.ceil(num2)+"<br />");




document.write(Math.random()+"<br />");


// returns a number between 0 ~ 1 (changes every time you refresh)




//]]1]]]]>


</script>




</head>






<body>




</body>




</html>



This English version was translated by Claude.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.

More on the author's page

Keep reading

Renewal

Why You Should Use .html Instead of .md Seeing Is Believing

Jul 25, 2026·1 min
Renewal

The Most Important Thing About AX

Jul 17, 2026·2 min
Renewal

디지털 기술과 혁신에 대한 논고(지탱하는 힘)

Jul 17, 2026·5 min