I am going through one of the JavaScript pattern, chaining.
Here I have code like this
function thisFunc(fullName){
    var that = this;
    this.firstName = function(name){
        fullName = fullName + name;
        return this;
    };
    this.lastName = function(name){
        fullName = fullName + ' ' + name;
        return that;
    };
    this.show = function(callback){
        callback(fullName);
        return that;
    };
}
var x = new thisFunc('');
x.firstName('Karthikeyan').lastName('Sundararajan').show(function(result){
    console.log(result);
});
var y = new thisFunc('');
console.log(y.firstName('Karthik'));
At the last line, am printing the return value of function firstName, I got output like this.
thisFunc { firstName: [Function], lastName: [Function], show: [Function] }
Why it is returning thisFunc which is parent of firstName, I expected it will return firstName. And I am seeing same result when I say, 'return this' and 'return that'.
 
    