Google
 

'Method'에 해당되는 글 1건

  1. 2008/02/14 바이웅 JavaScript - 객체내에서 메서드의 존재여부를 체크해야 할 경우.
스크립드를 처리함에 있어서 Validation체크를 할때 으례 객체나 메서드를 확인하여야 할 경우가 있습니다. 물론 변수도 마찬가지이지요.

function hasFunction(obj, functioName) {
    return obj && obj.functionName && obj.functionName instanceof Function
}


* Object 클래스의 프로토타입

Object.prototype.hasFunction = function(funcName) {
    return this && this.funcName && this.funcName instanceof Function;
}

var myObject = new myObject()

if (myObject.hasFunction("getArea")) {
    // to do..
}


http://perfdrug.tistory.com/52
2008/02/14 19:13 2008/02/14 19:13
    태그 연관글
    구글광고
    구독안내 Bywoong Blog는 주 2~3회 새글이 올라옵니다. 블로그 방문없이 업데이트 되는 글을 구독하세요. RSS . E-Mail . HanRSS . WZD . Google Reader . Bloglines

    댓글을 달아 주세요

    [로그인][오픈아이디란?]



    Loading...