Skip to content

Commit f5a52ff

Browse files
add new notes
1 parent b45f338 commit f5a52ff

9 files changed

+1549
-0
lines changed

notes/Hindi/22-hoisting.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
### Hoisting
2+
3+
hoisting ka matlab hai ki, kisi bhi variable or function declaration ko uske scope ke top par move kar diya jata hai, jabki unhe originally code mein declare kiya gaya ho. Jaise ki agar humne ek variable ko declare kiya hai aur usse pehle hi use karne ki koshish kari hai, toohamare code mein error aa sakta hai. Lekin hoisting ke dwara, variable ki declaration yaad rakhi jaati hai aur execution time par, undefined value assign ki jaati hai. Yehi process function declarations ke liye bhi apply hota hai.
4+
5+
For example, let's say you have the following code:
6+
7+
```
8+
console.log(x);
9+
var x = 10;
10+
```
11+
12+
Normally, this code would result in an error because `x` is undefined at the time it is being logged. However, due to hoisting, the variable declaration `var x` is moved to the top of its scope (in this case, the global scope), resulting in the following code:
13+
14+
```
15+
var x;
16+
console.log(x);
17+
x = 10;
18+
```
19+
20+
So when the code is actually executed, `x` has a value of `undefined`, which is what gets logged to the console.
21+
22+
Similarly, hoisting also applies to function declarations. For example:
23+
24+
```
25+
foo();
26+
27+
function foo() {
28+
console.log("Hello world!");
29+
}
30+
```
31+
32+
In this case, the function declaration for `foo()` is moved to the top of its scope, resulting in the following code:
33+
34+
```
35+
function foo() {
36+
console.log("Hello world!");
37+
}
38+
39+
foo();
40+
```
41+
42+
So when the code is executed, the function is already defined and can be called without any issues.

notes/Hindi/23-temporal-dead-zone.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### Temporal Dead Zone (TDZ)
2+
3+
TDZ ek period hai jahan hum ek varibale ko declare kar dete hain par usse pehle use access nahi kar sakte jab tak usse value assign nahi karte. Yeh ek error hai jo aata hai agar hum uss variable ko TDZ ke dauran access karte hain.
4+
5+
Temporal Dead Zone (TDZ) is a period in JavaScript where a declared variable cannot be accessed before it is assigned a value.
6+
7+
Let me explain this with an example: Suppose you declare a variable "x" using the keyword "let" inside a function:
8+
9+
```
10+
function myFunction() {
11+
console.log(x);
12+
let x = 5;
13+
}
14+
```
15+
16+
Now, when you call the function `myFunction()`, you will get an error that says "Cannot access 'x' before initialization". This is because `x` is still in the TDZ and has not been assigned a value yet.
17+
18+
To avoid this error, you need to move the console.log statement after the assignment of the variable:
19+
20+
```
21+
function myFunction() {
22+
let x = 5;
23+
console.log(x);
24+
}
25+
```
26+
27+
TDZ ek period hai jahan hum ek varibale ko declare kar dete hain par usse pehle use access nahi kar sakte jab tak usse value assign nahi karte. Yeh ek error hai jo aata hai agar hum uss variable ko TDZ ke dauran access karte hain.

notes/Hindi/24-debugging.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
### Debugging
2+
3+
Debugging ek process hai jahan hum apne code me errors ko dhoondte hai aur unhe fix karte hai. JavaScript me debugging ka matlab hota hai ki hum apne code ke errors ko dhoondh kar unhe solve karein taaki hamara code properly work kare.
4+
5+
Bahut se tools hote hai jaise console.log(), Chrome DevTools, aur Visual Studio Code debugger jo humein JavaScript code me error ko find karne me help karte hai.
6+
7+
Ek example ke liye, agar hum ek variable ko undefined value se initialize karte hai:
8+
9+
```javascript
10+
let name;
11+
console.log(name);
12+
```
13+
14+
Is case me console par "undefined" print hoga kyunki humne variable `name` ko koi value assign nahi ki hai. Is tarah se hum apne code me errors ko identify kar sakte hai aur unhe fix kar sakte hai.
15+
16+
Agar hum Visual Studio Code ka use karte hai toh hum break points laga kar debugger ka use kar sakte hai. Break points lagane ke baad jab hum apna code run karenge toh wo execution ke time pe break ho jayega aur hum uss point se aage execute kar sakte hai. Isse hum apne code ke errors ko easily findout kar sakte hai.
17+
18+
Ummid hai ki ye samajh me aa gaya hoga ki JavaScript debugging kya hota hai aur iska importance kya hai.
19+
20+
### Developer Tool
21+
22+
JavaScript Developer Tools are a set of features provided by web browsers to help developers debug and optimize their JavaScript code. These tools include a range of functions such as managing console logs, inspecting code execution, profiling performance, and analyzing network traffic.
23+
24+
For example, Google Chrome's DevTools provides a comprehensive set of developer tools that you can access by pressing the F12 key or right-clicking on any element in the page and selecting "Inspect." Once open, you will see several tabs that allow you to inspect the DOM, CSS, Network, Console, and more.
25+
26+
Using the Console tab, you can execute JavaScript code directly in the browser and log out the output. This is helpful for quickly testing code snippets and debugging issues. The Network tab shows all the HTTP requests made by the browser, allowing you to see which resources are being loaded and how long they take to load.
27+
28+
Additionally, DevTools has a Sources tab where you can insert breakpoints in your code to stop it at specific points, examine variable values and step through the code line by line.
29+
30+
Overall, these DevTools provide a powerful set of features that can help developers build and troubleshoot complex JavaScript applications more efficiently.
31+
32+
### Fixing errors
33+
34+
JavaScript mein errors ki shikayat aksar hoti hai, aur iske sahi karne ke liye kuch steps hote hain jo neeche bataye gaye hain:
35+
36+
1. Error message padhein: Jab bhi aapka code execute hone se pehle ya during execution mein error aata hai, toh console mein ek error message show hota hai. Is error message ko padhkar aapko pata chal jayega ki kis line mein error hai aur uski wajah kya hai.
37+
38+
2. Code ko review karein: Error message padhne ke baad aapko woh line of code dekhna chahiye jisme error hai. Us line of code ko carefully review karein aur dekhein ki kya galat likha hai.
39+
40+
3. Syntax ki sahiyta check karein: JavaScript ek syntax-based language hai, isliye aapki code mein sahi syntax hona bahut zaroori hai. Syntax error ko fix karne ke liye, aapko code ko carefully check karna hoga aur galti ko theek karna hoga.
41+
42+
4. Variables aur functions ki spelling ki jaanch karein: Aksar kabhi-kabhi variables aur functions ki spelling mistakes ho jati hai, jiske wajah se code mein error aata hai. Isliye, code mein use kiye gaye variables aur functions ki spelling ko carefully check karein.
43+
44+
5. Debugging tools ka istemaal karein: JavaScript mein debugging tools available hote hain jaise ki Chrome DevTools, Firefox Debugger, etc. In tools ka istemaal karke aap apne code mein errors ko easily trace kar sakte hain aur unhe sahi kar sakte hain.
45+
46+
Example:
47+
Maan lete hain ki aapne ek JavaScript function likha hai jo dono numbers ko add karta hai:
48+
49+
function addNumbers(a, b) {
50+
var sum = a + b;
51+
console.log(sum);
52+
}
53+
54+
Lekin agar aap is function ko call karte hain aur sirf ek number pass karte hain, toh error message show ho jayega:
55+
56+
addNumbers(5);
57+
58+
Error: Uncaught ReferenceError: b is not defined
59+
60+
Is error message se pata chalta hai ki kyonki aapne sirf ek parameter pass kiya hai, isliye 'b' variable undefined hai. Is error ko fix karne ke liye, aapko function call ko do parameters ke saath update karna hoga:
61+
62+
addNumbers(5, 10);
63+
64+
Output: 15
65+
66+
Is tarah se aap JavaScript mein errors ko fix kar sakte hain aur apne code ko smooth functioning karwa sakte hain.
67+
68+
### different types of errors .
69+
70+
Javascript mein kai prakar ke errors hote hai. Kuch common errors hain jaise Syntax errors, Reference errors, Type errors aur Range errors.
71+
72+
1. Syntax error: Ye error jab aata hai jab aapka code javascript language ke rules ke khilaaf hota hai. Jaise ki agar aapne ek statement ko likhne ke liye semi-colon (;) nahi lagaya to ye error aayega.
73+
74+
Example:
75+
76+
```
77+
// Invalid syntax
78+
let x = 5
79+
console.log(x)
80+
```
81+
82+
Ismein semi-colon missing hai statement ke end mein.
83+
84+
2. Reference error: Jab aap kisi varibale ko access karte hai jo exist nahi karta ya fir usko define nahi kiya gaya hai to ye error aata hai.
85+
86+
Example:
87+
88+
```
89+
// Accessing undefined variable
90+
console.log(x);
91+
```
92+
93+
Ismein variable x ka value define nahi kiya gaya hai.
94+
95+
3. Type error: Ye error tab hota hai jab aapka code ki type mismatch ho jati hai. Jaise ki aapne string ka operation number pe apply kiya ho.
96+
97+
Example:
98+
99+
```
100+
// Trying to use string method on a number
101+
let x = 123;
102+
console.log(x.toUpperCase());
103+
```
104+
105+
Ye error isliye aaya kyunki humne uppercase() method ko number mein use kiya hai, lekin ye method sirf string ke liye hota hai.
106+
107+
4. Range error: Jab aapka code range se bahar ho jata hai, jaise ki ek array ke element ke index ke bahar ho jaye ya fir ek number ki range se bahar ho jaye to ye error aata hai.
108+
109+
Example:
110+
111+
```
112+
// Trying to access an element outside the array
113+
let arr = [1, 2, 3];
114+
console.log(arr[3]);
115+
```
116+
117+
Ismein hum 4th index element ko access karne ki koshish kar rahe hai, jo ki array ke range se bahar hai.
118+
119+
In prakaron ke alawa bhi kai errors hote hai, par inmein se ye sabse common errors hai. Aapko javascript mein aane wale errors ka pata hona zaruri hai taaki aap unhe avoid kar sake aur apna code efficient tarike se likh sake.

0 commit comments

Comments
 (0)