[HTML] javascript 생성자

이현경·2021년 6월 2일
0

HTML

목록 보기
17/24
  • 생성자
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title></title>
    <script>
      function comFactory(cpuInfo, ramInfo, hddInfo) {
        this.cpu=cpuInfo;
        this.ram=ramInfo;
        this.hdd=hddInfo;

        this.totInfo=function(){
          document.write("제조업체: 한국전자 <br />");
          document.write("시스템종류: 64비트 운영체제 <br />");
        }
      }
      var speedCom=new comFactory("2.8GHZ", "2.0GB", "1TB");
      speedCom.totInfo();
      speedCom.cpu="111";
      speedCom.ram="8G";
      document.write(speedCom.cpu+"<br />");
      document.write(speedCom.ram+"<br />");
    </script>
  </head>
  <body>

  </body>
</html>
profile
25. 컴퓨터학과 졸업 / SQLD, 정보처리기사 취득

0개의 댓글