What exactly is Chainability?
Is it applicable in languages other than Javascript?
I researched a little, but the term washes me for disconnected articles, I believe it does not come out exactly what to look for to understand such a concept.
What exactly is Chainability?
Is it applicable in languages other than Javascript?
I researched a little, but the term washes me for disconnected articles, I believe it does not come out exactly what to look for to understand such a concept.
The term "Chainability" comes from the English chain , which means "chain" (not "chain" of prison) or "chain." So the term means " ability to create strings ".
Chainability is the ability, within the programming language, of an object to create chains (or concatenation) p>
jQuery is good at this:
$("#id")
.filter(".clickme")
.click(function(){
alert("You are now leaving the site.");
})
.end()
.filter(".hideme")
.click(function(){
$(this).hide();
return false;
})
.end();
See the various strings created for the same #id
element.
In pure JavaScript, an example of chaining would get values from a single function:
var Kitten = function() {
this.name = 'Garfield';
this.color = 'brown';
this.gender = 'male';
};
var bob = new Kitten();
console.log(bob.name); // retorna "Garfield"
console.log(bob.color); // retorna "brown"
In short, the concept of "chaining" is when a single object provides multiple values, instances, or functions. The advantage of this is that you can get multiple results without having to repeat codes.
Is it applicable in languages other than JavaScript?
This question can be answered by connoisseurs of languages other than JavaScript, since not everyone dominates all programming languages. But I believe many other advanced languages can have the same skill.
Search source: