Method chaining lets the receiver nominate a next receiver
- Dominant language
- JavaScript
- Stars
- 148k
- Forks
- 26.6k
- PR merge metrics
- No merged PRs in 30d
Description
Re https://github.com/airbnb/javascript#constructors--chaining
Code like
```js
luke.jump().setHeight(20);
```
enables luke to provide something other than luke itself as the receiver of the `setHeight` message. When this delegation of control is intended, such method chaining is great. OTOH, if the caller assumes it is equivalent to
```js
luke.jump();
luke.setHeight(20);
```
then they depend on a contract that luke might not obey. That doesn't necessarily mean the style should not be used, but the hazard needs to be explained clearly whenever this style is encouraged.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Constructors—Chaining section at the linked Airbnb JavaScript style guide page. Review how method chaining is currently encouraged and document that the returned receiver may differ from the original object when that distinction matters. Done means the section clearly explains this hazard without changing the recommended style.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100