prototype 예제 - 참거짓 경우
<button onclick="homzzang()">클릭</button> <p id="demo"></p> <script> Boolean.prototype.hzColor = function() { if (this.valueOf() == true) { return "blue"; } else { return "red"; } }; function homzzang() { var s = true; document.getElementById("demo").innerHTML = s.hzColor(); } </script> 결과보기
<button onclick="homzzang()">클릭</button>
<p id="demo"></p>
<script>
Boolean.prototype.hzColor = function() {
if (this.valueOf() == true) {
return "blue";
} else {
return "red";
}
};
function homzzang() {
var s = true;
document.getElementById("demo").innerHTML = s.hzColor();
</script>
결과보기
결과값: blue