Skip to content

Commit 9bcaa2b

Browse files
authored
Merge pull request #32 from theBstar/master
Code structure
2 parents 31542c1 + 621a5df commit 9bcaa2b

File tree

1 file changed

+66
-66
lines changed

1 file changed

+66
-66
lines changed
Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,159 @@
1-
# Code structure
1+
# कोड संरचना
22

3-
The first thing we'll study is the building blocks of code.
3+
पहली चीज जो हम अध्ययन करेंगे, वह है कोड की नींव की ईंटें (building blocks)।
44

5-
## Statements
5+
## उक्ति (Statements) [#उक्ति]
66

7-
Statements are syntax constructs and commands that perform actions.
7+
उक्ति कार्य करने वाले वाक्य रचना और आदेश हैं।
88

9-
We've already seen a statement, `alert('Hello, world!')`, which shows the message "Hello, world!".
9+
हमने पहले ही एक उक्ति देखा है, `alert('हेलो विश्व!')`, "हेलो विश्व" जो संदेश दिखाता है।
1010

11-
We can have as many statements in our code as we want. Statements can be separated with a semicolon.
11+
हम अपने कोड में जितने चाहें उतने उक्ति दे सकते हैं। उक्ति अर्धविराम से अलग किए जा सकते हैं।
1212

13-
For example, here we split "Hello World" into two alerts:
13+
उदाहरण के लिए, यहां हमने "हेलो विश्व!" को दो अलर्ट में विभाजित किया है:
1414

1515
```js run no-beautify
16-
alert('Hello'); alert('World');
16+
alert('हेलो!'); alert('विश्व');
1717
```
1818

19-
Usually, statements are written on separate lines to make the code more readable:
19+
आमतौर पर कोड को अधिक पठनीय बनाने के लिए अलग-अलग लाइनों पर उक्ति लिखे जाते हैं:
2020

2121
```js run no-beautify
22-
alert('Hello');
23-
alert('World');
22+
alert('हेलो');
23+
alert('विश्व');
2424
```
2525

26-
## Semicolons [#semicolon]
26+
## अर्धविराम [#अर्धविराम]
2727

28-
A semicolon may be omitted in most cases when a line break exists.
28+
लाइन ब्रेक मौजूद होने पर अधिकांश मामलों में अर्धविराम छोड़ा जा सकता है।
2929

30-
This would also work:
30+
यह कोड काम करेगा:
3131

3232
```js run no-beautify
33-
alert('Hello')
34-
alert('World')
33+
alert('हेलो')
34+
alert('विश्व')
3535
```
3636

37-
Here, JavaScript interprets the line break as an "implicit" semicolon. This is called an [automatic semicolon insertion](https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion).
37+
यहाँ, जावास्क्रिप्ट लाइन ब्रेक (एक पंक्ति का अंत) को "निहित" अर्धविराम के रूप में मानता है। इसे [automatic semicolon insertion](https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion) कहा जाता है।
3838

39-
**In most cases, a newline implies a semicolon. But "in most cases" does not mean "always"!**
39+
**ज्यादातर मामलों में, एक नई पंक्ति का अर्थ अर्धविराम है। लेकिन "ज्यादातर मामलों में" का अर्थ "हमेशा" नहीं होता है!**
4040

41-
There are cases when a newline does not mean a semicolon. For example:
41+
ऐसे मामले हैं जब एक नई लाइन का अर्थ अर्धविराम नहीं है। उदाहरण के लिए:
4242

4343
```js run no-beautify
4444
alert(3 +
4545
1
4646
+ 2);
4747
```
4848

49-
The code outputs `6` because JavaScript does not insert semicolons here. It is intuitively obvious that if the line ends with a plus `"+"`, then it is an "incomplete expression", so the semicolon is not required. And in this case that works as intended.
49+
कोड `6` आउटपुट करता है क्योंकि जावास्क्रिप्ट यहाँ अर्धविराम नहीं डालता है। यह सहज रूप से स्पष्ट है कि यदि उक्ति एक प्लस `" + "` के साथ समाप्त होता है, तो यह एक "अपूर्ण उक्ति" है, इसलिए अर्धविराम की आवश्यकता नहीं है। और इस मामले में जो इरादा के अनुसार काम करता है।
5050

51-
**But there are situations where JavaScript "fails" to assume a semicolon where it is really needed.**
51+
**लेकिन ऐसी परिस्थितियां भी हैं जहां जावास्क्रिप्ट अर्धविराम लगाने के लिए "विफल" होता है, जहां इसकी वास्तव में आवश्यकता होती है।**
5252

53-
Errors which occur in such cases are quite hard to find and fix.
53+
ऐसे मामलों में होने वाली त्रुटियां खोजने और ठीक करने में काफी कठिन हैं।
5454

55-
````smart header="An example of an error"
56-
If you're curious to see a concrete example of such an error, check this code out:
55+
````smart header="एक त्रुटि का उदाहरण"
56+
यदि आप ऐसी त्रुटि का ठोस उदाहरण देखने के लिए उत्सुक हैं, तो इस कोड को देखें:
5757
5858
```js run
5959
[1, 2].forEach(alert)
6060
```
6161
62-
No need to think about the meaning of the brackets `[]` and `forEach` yet. We'll study them later. For now, just remember the result of the code: it shows `1` then `2`.
62+
`[]` और 'forEach` के अर्थ के बारे में सोचने की आवश्यकता नहीं है। हम उनका अध्ययन बाद में करेंगे। अभी के लिए, बस कोड का परिणाम याद रखें: यह `1` दिखाता है फिर` 2`।
6363
64-
Now, let's add an `alert` before the code and *not* finish it with a semicolon:
64+
अब, कोड से पहले एक `अलर्ट` जोड़ें और अर्धविराम के साथ इसे *समाप्त न करें*:
6565
6666
```js run no-beautify
67-
alert("There will be an error")
67+
alert("इस कोड में एक त्रुटि होगी")
6868
6969
[1, 2].forEach(alert)
7070
```
7171
72-
Now if we run the code, only the first `alert` is shown and then we have an error!
72+
अब यदि हम कोड चलाते हैं, तो केवल पहले `alert` दिखाया जाता है और फिर एक त्रुटि होती है!
7373
74-
But everything is fine again if we add a semicolon after `alert`:
74+
लेकिन सब कुछ फिर से ठीक है अगर हम `alert` के बाद एक अर्धविराम जोड़ते हैं:
7575
```js run
76-
alert("All fine now");
76+
alert("अब सब ठीक है");
7777
7878
[1, 2].forEach(alert)
7979
```
8080
81-
Now we have the "All fine now" message followed by `1` and `2`.
81+
अब हमें "अब सब ठीक है" संदेश मिलता है और उसके बाद `1` और` 2` मिलते हैं।
8282
8383
84-
The error in the no-semicolon variant occurs because JavaScript does not assume a semicolon before square brackets `[...]`.
84+
बिना अर्धविराम के संस्करण में त्रुटि होती है क्योंकि `[...]` से पहले जावास्क्रिप्ट अर्धविराम नहीं मानता है।
8585
86-
So, because the semicolon is not auto-inserted, the code in the first example is treated as a single statement. Here's how the engine sees it:
86+
इसलिए, क्योंकि अर्धविराम को ऑटो-सम्मिलित नहीं किया गया है, पहले उदाहरण में कोड को एकल उक्ति माना जाता है। यहां बताया गया है कि इंजन इसे कैसे देखता है:
8787
8888
```js run no-beautify
89-
alert("There will be an error")[1, 2].forEach(alert)
89+
alert("इस कोड में एक त्रुटि होग")[1, 2].forEach(alert)
9090
```
9191
92-
But it should be two separate statements, not one. Such a merging in this case is just wrong, hence the error. This can happen in other situations.
92+
लेकिन यह दो अलग-अलग कथन होने चाहिए, एक नहीं। इस मामले में ऐसा विलय सिर्फ गलत है, इसलिए त्रुटि होती है। यह अन्य स्थितियों में हो सकता है।
9393
````
9494

95-
We recommend putting semicolons between statements even if they are separated by newlines. This rule is widely adopted by the community. Let's note once again -- *it is possible* to leave out semicolons most of the time. But it's safer -- especially for a beginner -- to use them.
95+
हम बयानों के बीच अर्धविराम लगाने की सलाह देते हैं, भले ही वे नई लाइनों से अलग हों। इस नियम को समुदाय द्वारा व्यापक रूप से अपनाया जाता है। आइए एक बार फिर ध्यान दें -- *यह संभव है* अधिकांश समय अर्धविरामों को छोड़ने के लिए। लेकिन यह सुरक्षित है -- विशेष रूप से नौसिखिए के लिए -- अर्धविराम का उपयोग करने के लिए।
9696

97-
## Comments [#code-comments]
97+
## टिप्पणियाँ [#टिप्पणियाँ]
9898

99-
As time goes on, programs become more and more complex. It becomes necessary to add *comments* which describe what the code does and why.
99+
जैसे-जैसे समय बीतता है, कोड अधिक से अधिक जटिल होते जाते हैं। यह आवश्यक है कि *टिप्पणियों* को जोड़ा जाए जो यह बताता है कि कोड क्या करता है और क्यों।
100100

101-
Comments can be put into any place of a script. They don't affect its execution because the engine simply ignores them.
101+
टिप्पणियाँ किसी स्क्रिप्ट के किसी भी स्थान पर डाली जा सकती हैं। वे इसके निष्पादन को प्रभावित नहीं करते हैं क्योंकि इंजन उन्हें अनदेखा करता है।
102102

103-
**One-line comments start with two forward slash characters `//`.**
103+
**एक-पंक्ति टिप्पणियाँ दो फ़ॉरवर्ड स्लैश वर्णों से शुरू होती हैं `//`.**
104104

105-
The rest of the line is a comment. It may occupy a full line of its own or follow a statement.
105+
शेष पंक्ति एक टिप्पणी है। यह अपनी खुद की एक पूरी लाइन पर कब्जा कर सकता है या एक उक्ति के पीछे आ सकता है.
106106

107-
Like here:
107+
जैसे यहाँ:
108108
```js run
109-
// This comment occupies a line of its own
110-
alert('Hello');
109+
// यह टिप्पणी स्वयं की एक लाइन पर है
110+
alert('हैलो');
111111

112-
alert('World'); // This comment follows the statement
112+
alert('विश्व'); // यह टिप्पणी उक्ति के बाद आई है
113113
```
114114

115-
**Multiline comments start with a forward slash and an asterisk <code>/&#42;</code> and end with an asterisk and a forward slash <code>&#42;/</code>.**
115+
**बहुस्तरीय टिप्पणियां आगे की स्लैश और तारांकन के साथ शुरू होती हैं <code>/&#42;</code> और एक तारांकन और एक आगे की स्लैश के साथ समाप्त होती हैं <code>&#42;/</code>.**
116116

117-
Like this:
117+
जैसे यहाँ:
118118

119119
```js run
120-
/* An example with two messages.
121-
This is a multiline comment.
120+
/* दो संदेशों के साथ एक उदाहरण।
121+
यह एक बहुस्तरीय टिप्पणी है।
122122
*/
123-
alert('Hello');
124-
alert('World');
123+
alert('हैलो');
124+
alert('विश्व');
125125
```
126126

127-
The content of comments is ignored, so if we put code inside <code>/&#42; ... &#42;/</code>, it won't execute.
127+
टिप्पणियों में कोड को अनदेखा किया जाता है, इसलिए यदि हम कोड को अंदर रखते हैं, <code>/&#42; ... &#42;/</code>, यह निष्पादित नहीं होगा।
128128

129-
Sometimes it can be handy to temporarily disable a part of code:
129+
कभी-कभी इस तकनीक का उपयोग करके कोड के एक भाग को अस्थायी रूप से अक्षम करना आसान होता है
130130

131131
```js run
132-
/* Commenting out the code
133-
alert('Hello');
132+
/* कोड टिप्पणी की गई है
133+
alert('हैलो');
134134
*/
135-
alert('World');
135+
alert('विश्व');
136136
```
137137

138-
```smart header="Use hotkeys!"
139-
In most editors, a line of code can be commented out by pressing the `key:Ctrl+/` hotkey for a single-line comment and something like `key:Ctrl+Shift+/` -- for multiline comments (select a piece of code and press the hotkey). For Mac, try `key:Cmd` instead of `key:Ctrl` and `key:Option` instead of `key:Shift`.
138+
```smart header="हॉट कुंजी का उपयोग करें!"
139+
अधिकांश संपादकों में, कोड की एक पंक्ति को एक-लाइन टिप्पणी के लिए `key: Ctrl + /` को दबाकर टिप्पणी की जा सकती है और बहुस्तरीय टिप्पणियों के लिए `key: Ctrl + Shift + /` (कोड का एक टुकड़ा चुनें और हॉटकी दबाएं)। Mac के लिए, `key: Ctrl` के बजाय `key: Cmd` और `key: Shift` के बजाय `key: Option` आज़माएं।
140140
```
141141

142-
````warn header="Nested comments are not supported!"
143-
There may not be `/*...*/` inside another `/*...*/`.
142+
````warn header="टिप्पणियाँ जो अन्य टिप्पणियों के अंदर हैं समर्थित नहीं हैं!"
143+
एक `/*...*/` के अंदर `/*...*/` नहीं हो सकता है
144144
145-
Such code will die with an error:
145+
इस तरह के कोड में त्रुटि होगी:
146146
147147
```js run no-beautify
148148
/*
149-
/* nested comment ?!? */
149+
/* नेस्टेड टिप्पणी ?!? */
150150
*/
151-
alert( 'World' );
151+
alert( 'विश्व' );
152152
```
153153
````
154154

155-
Please, don't hesitate to comment your code.
155+
कृपया, अपने कोड में टिप्पणी करने में संकोच न करें।
156156

157-
Comments increase the overall code footprint, but that's not a problem at all. There are many tools which minify code before publishing to a production server. They remove comments, so they don't appear in the working scripts. Therefore, comments do not have negative effects on production at all.
157+
टिप्पणियाँ कोड के समग्र आकार को बढ़ाती हैं, लेकिन यह बिल्कुल समस्या नहीं है। कई उपकरण हैं जो सर्वर पर प्रकाशित होने से पहले कोड को छोटा करते हैं। वे टिप्पणियों को हटा देते हैं, इसलिए वे काम करने वाली स्क्रिप्ट में दिखाई नहीं देते हैं। इसलिए, टिप्पणियों का अंतिम उत्पादन (production) पर नकारात्मक प्रभाव नहीं पड़ता है।
158158

159-
Later in the tutorial there will be a chapter <info:code-quality> that also explains how to write better comments.
159+
बाद में ट्यूटोरियल में एक अध्याय होगा <info:code-quality> जो यह भी बताता है कि बेहतर टिप्पणी कैसे लिखनी है।

0 commit comments

Comments
 (0)