Add examples for pure functions and destructuring defaults#704
Add examples for pure functions and destructuring defaults#704mohandand wants to merge 1 commit intoryanmcdermott:masterfrom
Conversation
Imran-imtiaz48
left a comment
There was a problem hiding this comment.
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)