neerajrathore / javascript-handbook

A handbook 📚 that summaries concepts of JavaScript.
https://javascript-handbook.vercel.app
MIT License
25 stars 39 forks source link

#59 promises in Async_Await and resolve_reject #60

Closed sajalgarg45 closed 1 month ago

sajalgarg45 commented 1 month ago

Pull Request Preview Title: Update README.md to Include Key Topics on Promises

Description:

This pull request updates the promise/Readme.md file by adding crucial topics that are essential for every JavaScript user to understand and implement in their work.

Changes Made:

Using Promises in Async/Await: Introduced the concept of async/await syntax, which is built on top of promises. This section explains how it allows for cleaner and more readable code when dealing with asynchronous operations. Using Promise.resolve() and Promise.reject(): Added information about the static methods Promise.resolve() and Promise.reject(). These methods are useful for quickly creating resolved or rejected promises, particularly in testing scenarios or when needing to enforce specific promise states. This enhancement aims to improve the understanding of the promise concept in JavaScript, making it more accessible to developers at all levels.

Additional Information:

The added columns provide essential insights into how promises work, which can significantly aid developers in implementing asynchronous programming effectively.

Screenshot 2024-10-05 at 10 42 58 PM
sajalgarg45 commented 1 month ago

Hey I think it is very important concept required for promise operations in Javascript , I think it is good for the docs , if you required any other doc related requirement feel free to ask me I am very helpful for you

neerajrathore commented 1 month ago

@sajalgarg45 can you explain how your addition is unique and how it differs from what's already present there?

sajalgarg45 commented 1 month ago

Unique Enhancements

1) Async/Await Syntax: What’s Added: Introduced async/await, a modern syntax built on Promises. Why It’s Unique: Simplifies asynchronous code, making it more readable and maintainable compared to traditional Promise chaining.

2) Promise.resolve() and Promise.reject(): What’s Added: Detailed sections on these static methods. Why It’s Unique: Provides tools for creating quickly resolved or rejected Promises, useful for testing and enforcing specific Promise states.

Differences from Existing Content - Depth: Goes beyond basic Promise usage by covering advanced patterns and utility methods. Practicality: Includes real-world use cases and examples, making the documentation more actionable. Clarity: Structured explanations with examples enhance understanding and usability.

I think it is very useful for you to merge this data in your repo as it add more insights and valuable features which anyone can use .

sajalgarg45 commented 1 month ago

Bro the issue #59 is assigned to me , you can merge it , I guarantee you it benefits other people , if you want me to add other info I can do it that as well

sajalgarg45 commented 1 month ago

Common Pitfalls with Closures

I also done the closure thing please check it , it is also beneficial for user when learning about closures

a. Memory Leaks Closures can inadvertently keep references to variables that are no longer needed, leading to memory leaks.

b. Looping with Closures A common mistake when using closures inside loops, especially with var.

Screenshot 2024-10-07 at 9 39 40 PM