How does JS?

1) How the clutch works ? I believe it is just a consistent calling methods, but can you provide more details.

2) never seen detailed descriptions of the job queue is regarding the promises, write only that each cycle of events (I mean the event loop) is added to a queue of promises that must be performed. You can read more about this?
June 3rd 19 at 19:40
2 answers
June 3rd 19 at 19:42
Solution
How the clutch works methods : Each method only modifies the object and returns it .
For example :

// define the class
var Kitten = function() {
 this.name = 'Garfield';
 this.color = 'brown';
 this.gender = 'male';
};

Kitten.prototype.setName = function(name) {
 this.name = name;
 return this;
};

Kitten.prototype.setColor = function(color) {
 this.color = color;
 return this;
};

Kitten.prototype.setGender = function(gender) {
 this.gender = gender;
 return this;
};

Kitten.prototype.save = function() {
console.log(
 'saving' + this.name + ' the ' +
 this.color + '' + this.gender + ' kitten...'
);

 // save to database here...

 return this;
};


and then

new Kitten()
.setName('Bob')
.setColor('black')
.setGender('male')
 .save();
Fill in the answer that this is called method chaining. - Austen.Thompson53 commented on June 3rd 19 at 19:45
about it already wrote above )) - Camryn.Schimmel commented on June 3rd 19 at 19:48
you when SO find some answer, I read all malozatratnye comments? - Austen.Thompson53 commented on June 3rd 19 at 19:51
when I'm looking for the answer, I study all that is available. In this topic about method chaining is written TWICE. You AibekAS.
If that's not enough, then the medicine is powerless. - Camryn.Schimmel commented on June 3rd 19 at 19:54
the one case where I regret that there is no cons. - Austen.Thompson53 commented on June 3rd 19 at 19:57
June 3rd 19 at 19:44
This is called method chaining , or simply chaining.

Each method needs not only to perform its action, and return a reference to the object.
For example:
// define the class
var Kitten = function() {
 this.name = 'Garfield';
 this.color = 'brown';
 this.gender = 'male';
};

Kitten.prototype.setName = function(name) {
 this.name = name;
 return this;
};

Kitten.prototype.setColor = function(color) {
 this.color = color;
 return this;
};

Kitten.prototype.setGender = function(gender) {
 this.gender = gender;
 return this;
};

Kitten.prototype.save = function() {
console.log(
 'saving' + this.name + ' the ' +
 this.color + '' + this.gender + ' kitten...'
);

 // save to database here...

 return this;
};


Usage:
new Kitten()
.setName('Bob')
.setColor('black')
.setGender('male')
 .save();
(code provided )

Find more questions by tags JavaScript