天天看點

鍊式程式設計

function Student(id,name){

    this.id = id;

    this.name = name;

    this.eat = function(food){

        console.log("吃"+food);

        return this;

    },

    this.sleep = function(){

        console.log("睡");

    }

    var stu =new Student(1001,"張三");

    stu.eat("").sleep().eat("").sleep().eat("").sleep().eat("").sleep();

    //鍊式程式設計     jqerry同理

繼續閱讀