티스토리 뷰

출처 : http://javascript.crockford.com/prototypal.html


Object.prototype.begetObject = function () {
    function F() {}
    F.prototype = this;
    return new F();
};

newObject = oldObject.begetObject();



if (typeof Object.create !== 'function') {
    Object.create = function (o) {
        function F() {}
        F.prototype = o;
        return new F();
    };
}
newObject = Object.create(oldObject);


'웹개발 > Javascript' 카테고리의 다른 글

자바스크립트 SOLID 원칙  (0) 2014.02.26
자바스크립트 잘하기  (0) 2014.02.26
Learning Advanced JavaScript  (0) 2014.02.26
자바스크립트 정규 표현식!  (0) 2013.12.19
javascript Cookie - 쿠키 객체  (0) 2013.05.29
댓글
D-DAY
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함