- Notifications
You must be signed in to change notification settings - Fork12.5k
Add examples for pure functions and destructuring defaults#704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Add examples for pure functions and destructuring defaults#704
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Imran-imtiaz48 left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This section provides a clear and concise explanation of the difference between pure functions and side effects, with practical examples to illustrate both good and bad practices. The examples are especially effective in demonstrating why pure functions are preferable—highlighting predictability, testability, and ease of refactoring. The "bad" code block effectively showcases common pitfalls like mutating external state, while the "good" example demonstrates clean and functional code by returning new values instead of modifying existing ones. The added inline comments are helpful for reinforcing key points. Overall, this is a solid addition to your documentation or GitHub README—well-structured, informative, and easy to understand.
This PR adds two new best-practice examples to the guide:
Pure Functions vs. Side Effects (in the Functions section)
Destructuring Defaults & Nested Destructuring (in the Objects and Data Structures section)