Js链式调用

jQuery实习链式调用是在结构体内放回对象本身

        var obj = {
            name:'ghost',
            age: 18,
            say:function(){
                console.log(this.name)
            },
            eat:function(){
                console.log('I am ertting')

            }
        }
        console.log(obj.say()) //undefined 返回值为undefind所以不能链式调用

        var obj = {
            name:'ghost',
            age: 18,
            say:function(){
                console.log(this.name)
                return this
            },
            eat:function(){
                console.log('I am eatting')
                return this

            }
        }
        console.log(obj.say()) //obj对象
      obj.say().eat()//ghost I am eatting
上一篇:JAVA子类继承父类的成员变量以及方法


下一篇:Nginx+Lua(OpenResty)搭建以及成果测试(3)!