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