hi All,
I have question around Douglas Crockford "method" method.

Function.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
function azerizor(value) {

azerizor.method('toString', function () {

    return this.value;
var me = new azerizor('salam').toString();


this is it. But here arises question regarding return this?
what does mean here return this? this method works without return this. I have read about that. so that one say that it is for chaining. But i didnt understand how can i use chaining using this "method" function. Thanks in advance for attention. I will wait your responses!

Re: Confusing about chaining 80 80

Chaining is calling one function after another on the same object. Returning the object is a way to accomplish that. It allows you to write.

Re: Confusing about chaining 80 80

Thank you very much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.