Wednesday, January 4, 2012

Chaining Pattern

With Chaining Pattern you can call object methods one after the others without assigning the result to other variables or break them in multiple statement or lines.

For example:


This pattern is only useful when object functions do not have to special return so, this pattern can  implemented by returning this in each object function.

For example:

var myelm={
        hide: function(second){
                //code for hiding
                 return this;

        fadeIn: function(second){
                //code for fading
                 return this;


No comments:

Post a Comment