Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
mohandand wants to merge1 commit intoryanmcdermott:master
base:master
Choose a base branch
Loading
frommohandand:pure-functions-and-destructuring-topics

Conversation

mohandand
Copy link

This PR adds two new best-practice examples to the guide:

  1. Pure Functions vs. Side Effects (in the Functions section)

    • Demonstrates the importance of avoiding side effects
    • Includes good vs. bad examples with clear reasoning
  2. Destructuring Defaults & Nested Destructuring (in the Objects and Data Structures section)

    • Shows how to provide safe defaults and avoid runtime errors
    • Includes clean parameter handling with modern syntax

Copy link

@Imran-imtiaz48Imran-imtiaz48 left a 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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@Imran-imtiaz48Imran-imtiaz48Imran-imtiaz48 left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@mohandand@Imran-imtiaz48

[8]ページ先頭

©2009-2025 Movatter.jp