English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
prototype속성은 Boolean() 객체에 속성과 메서드를 추가할 수 있도록 합니다.
주의:prototype는 전역 속성으로 거의 모든 객체(숫자, 배열, 문자열, 날짜 등)에서 사용할 수 있습니다.
Boolean.prototype.name = value
새 부울 메서드를 생성하여 문단의 배경을 변경합니다:
Boolean.prototype.isEven = function() { if (this.valueOf() == true) { return "lightgreen"; } else { return "red"; } };
그런 다음 부울 값을 생성하고 isEven() 메서드를 호출합니다:
function myFunc() { var a = true; document.getElementById('result').style.background = a.isEven(); }
모든 브라우저는 prototype 속성을 완전히 지원합니다:
속성 | |||||
prototype | 예 | 예 | 예 | 예 | 예 |