JavaScript_13设计模式(链式编程【七】)简单链式编程实现

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_36282409/article/details/84290312
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>New Web Project</title>
    <script type="text/javascript" charset="UTF-8">
        /**
         * 简单链式编程实现:
         * 
         */
        
        function Cat(){
           this.run=function(){
               alert('the cat is run.. ');
               return this;
           };
           this.eat=function(){
                 alert('the cat is eat.. '); 
                 return this;
           };
           this.sleep=function(){
                 alert('the cat is sleep.. '); 
                 return this;
           }      
           }       
           var cat1=new Cat();
           cat1.run().eat().sleep();   
    </script>
</head>
<body>
    <h1>New Web Project Page</h1>
</body>

猜你喜欢

转载自blog.csdn.net/weixin_36282409/article/details/84290312