Object Method Chaining in jQuery

[javascript]
var truck = function() {

this.turnLeft = function {

// turn left
return this;

}

this.turnRight = function {

// turn right
return this;

}

this.goReallyFast = function {

// go fast!
return this;

}

};

// My get-away plan
var myTruck = new truck();
myTruck.turnLeft().turnRight().goReallyFast();
[/javascript]

Leave a Reply