개체에 지정된 이름을 가진 속성이 있는지 여부를 나타내는 부울값을 반환한다.
![]() | Script | [bVal=]Object.hasOwnProperty(propertyName) |
필수적인 요소로서 속성이름의 문자열 값이다.
반환값 bVal은 속성이 있는가를 나타내는 부울값이다.
true | 지정된 이름의 속성이 있다. |
false | 지정된 이름의 속성이 없다. |
이 메서드는 개체의 프로토타입 체인에 propertyName 속성이 있는지 여부는 확인하지 않으므로 속성은 개체 자체의 구성원이어야 한다.
적용 | Object 개체 |
참조 | prototype 속성 | isPrototypeOf 속성 | hasOwnProperty 속성 | propertyIsEnumerable 속성 | in 연산자 |
![]() | hasOwnProperty 메서드⇒ | ![]() | ![]() ![]() ![]() |
<SCRIPT> var br='<BR>'; // 줄바꿈 document.write(String.prototype.hasOwnProperty('split')+br); // String 개체는 split 메서드를 공유하여 true var str=new String('hasOwnProperty Test'); // 문자열 변수 지정 document.write(str.hasOwnProperty('split')+br); // str 변수에는 split 메서드가 없으므로 false document.write(String.prototype.hasOwnProperty('concat')+br); // String 개체는 concat 메서드가 있으므로 true document.write(String.prototype.hasOwnProperty('bgColor')+br); // String 개체는 bgColor 메서드가 없으므로 false </SCRIPT>
![]() | hasOwnProperty 메서드 | ⇒ | ![]() ![]() |
최종 수정: 06/29/2025 04:35:11 | ![]() All right reserved | 비정상적인 방식으로 프레임없이 페이지에 접속하면 자주 오류가 발생됩니다. 오류가 나면 정상적 접속으로 시도해 보세요. | http://koxo.com/lang/js/method/hasOwnProperty.html |