级联函数

<!DOCTYPE html>  
<html>  
  
    <head>  
        <meta charset="UTF-8">  
        <title></title>  
        <script>  
            /*级联函数重点在于 把当前原型对象指针返回, 即可调用其他方法*/  
            function person() {  
                this._lian = "";  
                this._zui = "";  
                this._tui = "";  
            }  
            person.prototype = {  
                setLian: function() {  
                    this._lian = "大脸";  
                    return this;  
                },  
                setZui: function() {  
                    this._zui = "大嘴";  
                    return this;  
                },  
                setTui: function() {  
                    this._tui = "大腿";  
                    return this;  
                }  
            }  
            var p = new person();  
            p.setLian().setZui().setTui();  
            console.log(p);  
        </script>  
    </head>  
  
    <body>  
    </body>  
  
</html>  
View Code

 

posted on 2017-12-24 21:11  汉三  阅读(158)  评论(0)    收藏  举报

导航