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

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

NS
normalstory
cover image



Function declarations are done as follows.

1) Function declaration inside the header.

    function 생성자 함수명(매개변수1,매개변수2)

2) Object creation inside the body.
    객체이름=new 생성자 함수명(매개변수1,매개변수2)
 

Do you remember?
The parameters we mentioned before... those guys are back again...




 


<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> 함수 객체 </title>




<script type="text/javascript">


//<!CDATA[


function computer(cpu,ram,hdd/*인자값*/){


this.cpu=cpu; //this.속성=매개변수 ; mycomputer=this


this.ram=ram;


this.hdd=hdd;


}


function noramlstory(design,play,work/*인자값*/){


this.design=design; //this.속성=매개변수 ; mycomputer=this


this.play=play;


this.work=work;


}


//]]1]]]]>


</script>




</head>






<body>


<script type="text/javascript">


mycomputer=new computer("p4","4G","200G"); // mycomputer=this


yourcomputer=new computer("p2","1G","100G");


document.write("<h3>your computer</h3>");


document.write("cpu :" + yourcomputer.cpu + " | ");


document.write("ram :" + yourcomputer.ram + " | ");


document.write("hdd :" + yourcomputer.hdd + " | ");






mmm=new noramlstory("p4","4G","200G");


document.write("<h3> noramlstory</h3>");


document.write("design :" + mmm.design + " | ");


document.write("play:" + mmm.play + " | ");


document.write("work :" +mmm.work + " | ");


</script>




</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

Steadily, for the long haul, without burning out

Mar 31, 2026·9 min
Renewal

Tech-life balance

Feb 7, 2026·3 min
Renewal

Humanality, by Park Jeong-ryeol

Feb 7, 2026·11 min