Skip to content

Commit

Permalink
Merge pull request #6885 from meezwhite/docs/issue-6797
Browse files Browse the repository at this point in the history
docs(styleguide): add section on chaining
  • Loading branch information
Qianqianye authored Mar 19, 2024
2 parents e947f2e + a7e3600 commit 85fbe7c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions contributor_docs/documentation_style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Our community is large and diverse. Many people learn to code using p5.js, and a
- [Arrays](#arrays)
- [Functions](#functions)
- [Arrow Functions](#arrow-functions)
- [Chaining](#chaining)
- [Classes](#classes)
- [Assets](#assets)

Expand Down Expand Up @@ -1041,6 +1042,30 @@ function processImage(img) {
// Good.
[1, 2, 3].map((number) => number * number);
```
**[⬆ back to top](#table-of-contents)**

## Chaining

* Use individual function calls instead of function chaining.

> Why? To accommodate users who may not be familiar with the concept of function chaining.
```javascript
// Bad.
fill(0)
.strokeWeight(6)
.textSize(20);

// Bad.
fill(0).strokeWeight(6).textSize(20);

// Good.
fill(0);
strokeWeight(6);
textSize(20);
```

**[⬆ back to top](#table-of-contents)**

## Classes

Expand Down

0 comments on commit 85fbe7c

Please sign in to comment.