JavaScript_原型链

2023-05-15,,

function Fn(){
            this.test1 = function(){
                console.log('test1()');
            };
        }

        Fn.prototype.test2 = function(){
            console.log('test2()');
        };

        var fn = new Fn();

        fn.test1();//"test1()"
        fn.test2();//"test2()"
        console.log(fn.toString());//"[object Object]"
        fn.test3();//报错,"undefined is not a function"

《JavaScript_原型链.doc》

下载本文的Word格式文档,以方便收藏与打印。