Questions

Shalow Copy

Shalow Copy: Shalow copy upper se copy kr leta hn but deep copy nahi kr pata
example:

ye name ko or age ko copy kr ly ga but nested hoi hoi chezon ko nahi kr pay ga jese facebook twiiter ko copy nahi kr pay ga

use spread operator {...obj} to get deep copy from spread operator but it copy objects not deep and nested object

Deep Copy

Deep Copy:Deep copy deep tk objects ko copy kr leta hn means proper copy krna nested object and array ko deep copy krna.

ye niche ek method hn deep copy kar raha hn jo ke just practice ke liye hn, ye ham Interview me nahi batynge

ye niche ek recursive function hn jo ke deep copy kr raha hn object ki or arrays ki agr koi premitive data dynge to wo return kr dy ga

What is a Promise?

PromisesA Promise ek object hai jo asynchronous code ke result ko manage karta hai.
Yeh 3 states me ho sakta hai:



How to Use Promises?

Types of Promises

1) Promise.all()



2) Promise.allSettled()


Example:


Output:



3) Promise.race()


Example:


4) Promise.any() (ES2021)


Example:


5) Promise.resolve()


Example:


6) Promise.reject()


Example:


Conclusion - Promises

What is Methods

function inside object is called Methods

Spread Operator (...)

Spread operator ek modern JavaScript feature hai jo ek array ya object ke elements ko alag-alag (spread) karne ke liye use hota hai.

Example:

Rest Operator (...)

Rest operator ka use multiple elements ko ek array ya object ke andar "collect" karne ke liye hota hai. Ye zyada tar destructuring aur functions ke arguments handle karne ke liye use hota hai.

Example:

Use of Spread Operator and Rest Operator

Spread Operator:


Rest Operator:

Destructuring in JavaScript

Destructuring in JavaScriptDestructuring ek JavaScript syntax hai jo arrays aur objects ke elements ko extract (nikalne) aur unhe alag variables mein store karne ke liye use hoti hai. Iska kaam hai code ko concise aur readable banana.

Types of Destructuring:


1) Array Destructuring

Array destructuring ka use array ke elements ko alag variables mein extract karne ke liye hota hai.


2) Object Destructuring

Array destructuring ka use array ke elements ko alag variables mein extract karne ke liye hota hai.

Conclusion Destructuring ek powerful aur modern JavaScript feature hai jo code ko concise, readable, aur manageable banata hai. Ye har modern JavaScript developer ka tool hai, especially jab aapko APIs, React, ya complex data structures ke sath kaam karna ho.