2 ms·
I like chaining because it emphasizes that a set of method calls is part of one discrete action involving one object. For example, take adding a header to some
by tikhonj 15y ago
I like chaining because it emphasizes that a set of method calls is part of one discrete action involving one object.
For example, take adding a header to some text: it's one action, but it involves multiple steps. First I create the actual element, then I give it a class name, add some text and finally insert it in the DOM. I think chaining not only makes the code easier to read (and type, although that isn't particularly important), but also makes its semantics clearer.
- wavephorm 15y agoThat's what functions are for. Chainable methods don't make multiple step operations more concise.