그래서 new를 붙이지 않고 생성자 함수를 호출하면 this.name = name;에서 window.name의 값을 바꾸게 됩니다.

    function Monster(name, hp, att) { 
      this.name = name;
      this.hp = hp; 
      this.att = att; 
    }
    const monster1 = Monster('슬라임', 25, 10); // window 객체의 name, hp, att 수정

    그림 2-38 수정된 window 객체

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.