function Person() {} // 생성자로 사용할 함수 생성 // Person의 Prototype Object에 속성과 메서드를 정의 한다. Person.prototype.name = "nam"; Person.prototype.age = 33; Person.prototype.sayName = function() { document.write(this.name); }; var person1 = new Person(); function hasPrototypeProperty(instanceObj, propertyName) { // 인스턴스 객체에 propertyName이 없고, // propertyName에 접근 가능하면 // propertyName은 prototype 채인에 속해 있다. return !instanceObj.hasOwnProperty(propertyName) && (propertyName in instanceObj); } document.write(hasPrototypeProperty(person1, "name")); // true name속성이 prototype에 있음 document.write("<br>"); person1.name = "kim"; document.write(hasPrototypeProperty(person1, "name")); // false name속성이 인스턴스에 있음