function Person() {}; // 생성자 함수 생성 var person1 = new Person(); // person1 인스턴스 생성 Person.prototype.sayHi = function() { // 기존의 prototype 객체(이것을 1번) 메서드 추가 document.write("Hi <br>"); } person1.sayHi(); // Hi 메서드가 작동됩니다. person1의 [[prototype]] 포인터는 1번을 가리킴 // Person.prototype 이 새로운 객체(이것을 2번)를 가리키게 합니다. Person.prototype = { constructor: Person, // 생성자 함수와 연결합니다. name: "nam", age: "33", sayName: function() { document.write(this.name); } }; Object.defineProperty(Person.prototype, "constructor", { enumerable: false // for-in 등에서 나열되지 않도록 처리 }); var person2 = new Person(); // Person2의 [[prototype]] 포인터는 2번을 가리킴 try { person2.sayName(); //nam document.write("<br>"); person1.sayName(); // person1 } catch (err) { document.write(err); // TypeError: person1.sayName is not a function }