<html>
<head>

</head>
<body>
<ul><h2>객체</h2>
<script type="text/jscript">
function print()
{
 document.write("<br> cpu = "+this.cpu+", ram = "+this.ram+", hdd = "+this.hdd);
}
//Computer 개체생성
function Computer(cpu,ram,hdd)
{
 //thisp : 멤버필드
 this.cpu = cpu;
 this.ram = ram;
 this.hdd = hdd;

 //this.infoWrite : 메소드 이름
 this.infoWrite = print;
}
myComputer = new Computer("펜티엄4","1Giga","100Giga");
document.write("<br> cpu = "+myComputer.cpu);
document.write("<br> ram = "+myComputer.ram);
document.write("<br> hdd = "+myComputer.hdd);

myComputer.infoWrite();

yourComputer = new Computer("펜티엄","2Giga","400Giga");
yourComputer.infoWrite();
</script>
</ul>
</body>
</html>

Posted by 말없제이
,