0% found this document useful (0 votes)
22 views3 pages

Advanced JavaScript Guide in Urdu/English

The document provides a comprehensive guide to Advanced JavaScript, covering topics such as execution context, hoisting, closures, promises, async/await, event loop, prototype, ES6+ features, error handling, and Node.js. It includes practical examples and best practices, along with interview questions to test understanding. The final advice emphasizes the importance of practice in mastering JavaScript.

Uploaded by

mianmhassaan949
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Advanced JavaScript Guide in Urdu/English

The document provides a comprehensive guide to Advanced JavaScript, covering topics such as execution context, hoisting, closures, promises, async/await, event loop, prototype, ES6+ features, error handling, and Node.js. It includes practical examples and best practices, along with interview questions to test understanding. The final advice emphasizes the importance of practice in mastering JavaScript.

Uploaded by

mianmhassaan949
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Advanced JavaScript Complete Guide (Urdu + English Mix)

1. Introduction
JavaScript aik dynamic, high-level programming language hai jo mostly browsers aur [Link]
environment mein chalti hai. Yeh single-threaded hoti hai lekin asynchronous behavior ke zariye
multiple tasks handle kar sakti hai.

2. Execution Context & Hoisting


Jab JS code run hota hai to sabse pehle Global Execution Context banta hai. Hoisting ka matlab
hai ke variable aur function declarations top pe le jaaye jaate hain.
Example:
```javascript
[Link](a); // undefined
var a = 5;
```

3. Scope & Closures


Scope decide karta hai ke variable kahan access ho sakta hai. Closure tab banta hai jab aik
inner function apne parent scope ke variables ko access karta hai even after the parent
function has returned.
Example:
```javascript
function outer(){
let count = 0;
return function(){ count++; return count; }
}
const counter = outer();
[Link](counter()); // 1
[Link](counter()); // 2
```

4. Promises & Async/Await


Promise aik object hai jo asynchronous operation ka result represent karta hai.
Example:
```javascript
function getData(){
return new Promise(resolve => {
setTimeout(()=>resolve('Data received!'), 1000);
});
}
getData().then([Link]);
```

Async/Await syntax code ko cleaner banata hai:


```javascript
async function show(){
const data = await getData();
[Link](data);
}
show();
```

5. Event Loop & Call Stack


JavaScript single-threaded hai. Event Loop handle karta hai asynchronous tasks jaise
setTimeout, fetch, etc. Jab call stack empty hota hai tab callback queue ke functions execute
hote hain.

6. Prototype & Inheritance


Har JS object ke paas aik hidden property hoti hai `__proto__`, jo prototype chain ke zariye
inheritance enable karti hai.
Example:
```javascript
function Person(name){ [Link] = name; }
[Link] = function(){ [Link]('Hello ' + [Link]); }
const p1 = new Person('Ali');
[Link]();
```
7. ES6+ Features
- Arrow Functions
- Template Literals
- Destructuring
- Spread / Rest Operators
- Modules (import/export)
- Optional chaining (?.)
Example:
```javascript
const obj = {a:{b:2}};
[Link](obj?.a?.b);
```

8. Error Handling
Try/Catch ka use error handle karne ke liye hota hai.
```javascript
try {
let result = riskyFunction();
} catch(err) {
[Link]('Error:', [Link]);
} finally {
[Link]('Done');
}
```

9. Fetch API Example (Mini Project)


Weather app example:
```javascript
async function getWeather(city){
const res = await fetch(`[Link]
const data = await [Link]();
[Link]([Link], [Link].temp_c);
}
getWeather('Lahore');
```

10. [Link] Overview


[Link] ek runtime environment hai jo JS ko browser ke bahar run karne deta hai. Isme modules,
file system, HTTP server aur APIs use kiye ja sakte hain.
Example server:
```javascript
const http = require('http');
[Link]((req,res)=>{
[Link]('Hello from Node!');
}).listen(3000);
```

11. Tips & Best Practices


- Use const/let instead of var
- Always handle promises with try/catch
- Avoid global variables
- Use linters (ESLint)
- Comment clean aur meaningful rakho
12. Interview Level Questions
1. Difference between var, let, const?
2. What is event delegation?
3. How closures work?
4. Difference between call, apply, bind?
5. What is debouncing and throttling?
6. What is the use of promises?
7. Difference between == and ===?
8. How does the event loop work?

13. Final Advice


JavaScript seekhne ka best tareeqa practice hai. Browser console aur online editors (CodePen,
JSFiddle, VSCode) mein code likh kar test karo. Har din chhota project banao, jaise calculator,
to-do app, ya API se data fetch karna.

Generated by ChatGPT | Advanced JavaScript Guide | Practice makes perfect.

You might also like