You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/02-structure/article.md
+41-41Lines changed: 41 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -38,101 +38,101 @@ alert('विश्व')
38
38
39
39
**ज्यादातर मामलों में, एक नई पंक्ति का अर्थ अर्धविराम है। लेकिन "ज्यादातर मामलों में" का अर्थ "हमेशा" नहीं होता है!**
40
40
41
-
There are cases when a newline does not mean a semicolon. For example:
41
+
ऐसे मामले हैं जब एक नई लाइन का अर्थ अर्धविराम नहीं है। उदाहरण के लिए:
42
42
43
43
```js run no-beautify
44
44
alert(3+
45
45
1
46
46
+2);
47
47
```
48
48
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`आउटपुट करता है क्योंकि जावास्क्रिप्ट यहाँ अर्धविराम नहीं डालता है। यह सहज रूप से स्पष्ट है कि यदि उक्ति एक प्लस `" + "` के साथ समाप्त होता है, तो यह एक "अपूर्ण उक्ति" है, इसलिए अर्धविराम की आवश्यकता नहीं है। और इस मामले में जो इरादा के अनुसार काम करता है।
50
50
51
-
**But there are situations where JavaScript "fails" to assume a semicolon where it is really needed.**
51
+
**लेकिन ऐसी परिस्थितियां भी हैं जहां जावास्क्रिप्ट अर्धविराम लगाने के लिए "विफल" होता है, जहां इसकी वास्तव में आवश्यकता होती है।**
52
52
53
-
Errors which occur in such cases are quite hard to find and fix.
53
+
ऐसे मामलों में होने वाली त्रुटियां खोजने और ठीक करने में काफी कठिन हैं।
54
54
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
+
यदि आप ऐसी त्रुटि का ठोस उदाहरण देखने के लिए उत्सुक हैं, तो इस कोड को देखें:
57
57
58
58
```js run
59
59
[1, 2].forEach(alert)
60
60
```
61
61
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`।
63
63
64
-
Now, let's add an `alert` before the code and *not* finish it with a semicolon:
64
+
अब, कोड से पहले एक `अलर्ट` जोड़ें और अर्धविराम के साथ इसे *समाप्त न करें*:
65
65
66
66
```js run no-beautify
67
-
alert("There will be an error")
67
+
alert("इस कोड में एक त्रुटि होगी")
68
68
69
69
[1, 2].forEach(alert)
70
70
```
71
71
72
-
Now if we run the code, only the first `alert` is shown and then we have an error!
72
+
अब यदि हम कोड चलाते हैं, तो केवल पहले `alert` दिखाया जाता है और फिर एक त्रुटि होती है!
73
73
74
-
But everything is fine again if we add a semicolon after `alert`:
74
+
लेकिन सब कुछ फिर से ठीक है अगर हम `alert` के बाद एक अर्धविराम जोड़ते हैं:
75
75
```js run
76
-
alert("All fine now");
76
+
alert("अब सब ठीक है");
77
77
78
78
[1, 2].forEach(alert)
79
79
```
80
80
81
-
Now we have the "All fine now" message followed by `1` and `2`.
81
+
अब हमें "अब सब ठीक है" संदेश मिलता है और उसके बाद `1` और` 2` मिलते हैं।
82
82
83
83
84
-
The error in the no-semicolon variant occurs because JavaScript does not assume a semicolon before square brackets `[...]`.
84
+
बिना अर्धविराम के संस्करण में त्रुटि होती है क्योंकि `[...]` से पहले जावास्क्रिप्ट अर्धविराम नहीं मानता है।
85
85
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
+
इसलिए, क्योंकि अर्धविराम को ऑटो-सम्मिलित नहीं किया गया है, पहले उदाहरण में कोड को एकल उक्ति माना जाता है। यहां बताया गया है कि इंजन इसे कैसे देखता है:
87
87
88
88
```js run no-beautify
89
-
alert("There will be an error")[1, 2].forEach(alert)
89
+
alert("इस कोड में एक त्रुटि होग")[1, 2].forEach(alert)
90
90
```
91
91
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
+
लेकिन यह दो अलग-अलग कथन होने चाहिए, एक नहीं। इस मामले में ऐसा विलय सिर्फ गलत है, इसलिए त्रुटि होती है। यह अन्य स्थितियों में हो सकता है।
93
93
````
94
94
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
+
हम बयानों के बीच अर्धविराम लगाने की सलाह देते हैं, भले ही वे नई लाइनों से अलग हों। इस नियम को समुदाय द्वारा व्यापक रूप से अपनाया जाता है। आइए एक बार फिर ध्यान दें -- *यह संभव है* अधिकांश समय अर्धविरामों को छोड़ने के लिए। लेकिन यह सुरक्षित है -- विशेष रूप से नौसिखिए के लिए -- अर्धविराम का उपयोग करने के लिए।
96
96
97
-
## Comments[#code-comments]
97
+
## टिप्पणियाँ[#टिप्पणियाँ]
98
98
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
+
जैसे-जैसे समय बीतता है, कोड अधिक से अधिक जटिल होते जाते हैं। यह आवश्यक है कि *टिप्पणियों* को जोड़ा जाए जो यह बताता है कि कोड क्या करता है और क्यों।
100
100
101
-
Comments can be put into any place of a script. They don't affect its execution because the engine simply ignores them.
101
+
टिप्पणियाँ किसी स्क्रिप्ट के किसी भी स्थान पर डाली जा सकती हैं। वे इसके निष्पादन को प्रभावित नहीं करते हैं क्योंकि इंजन उन्हें अनदेखा करता है।
102
102
103
-
**One-line comments start with two forward slash characters`//`.**
103
+
**एक-पंक्ति टिप्पणियाँ दो फ़ॉरवर्ड स्लैश वर्णों से शुरू होती हैं`//`.**
104
104
105
-
The rest of the line is a comment. It may occupy a full line of its own or follow a statement.
105
+
शेष पंक्ति एक टिप्पणी है। यह अपनी खुद की एक पूरी लाइन पर कब्जा कर सकता है या एक उक्ति के पीछे आ सकता है.
106
106
107
-
Like here:
107
+
जैसे यहाँ:
108
108
```js run
109
-
//This comment occupies a line of its own
110
-
alert('Hello');
109
+
//यह टिप्पणी स्वयं की एक लाइन पर है
110
+
alert('हैलो');
111
111
112
-
alert('World'); //This comment follows the statement
112
+
alert('विश्व'); //यह टिप्पणी उक्ति के बाद आई है
113
113
```
114
114
115
-
**Multiline comments start with a forward slash and an asterisk <code>/*</code> and end with an asterisk and a forward slash <code>*/</code>.**
115
+
**बहुस्तरीय टिप्पणियां आगे की स्लैश और तारांकन के साथ शुरू होती हैं <code>/*</code> और एक तारांकन और एक आगे की स्लैश के साथ समाप्त होती हैं <code>*/</code>.**
116
116
117
-
Like this:
117
+
जैसे यहाँ:
118
118
119
119
```js run
120
-
/*An example with two messages.
121
-
This is a multiline comment.
120
+
/*दो संदेशों के साथ एक उदाहरण।
121
+
यह एक बहुस्तरीय टिप्पणी है।
122
122
*/
123
-
alert('Hello');
124
-
alert('World');
123
+
alert('हैलो');
124
+
alert('विश्व');
125
125
```
126
126
127
-
The content of comments is ignored, so if we put code inside <code>/* ... */</code>, it won't execute.
127
+
टिप्पणियों में कोड को अनदेखा किया जाता है, इसलिए यदि हम कोड को अंदर रखते हैं, <code>/* ... */</code>, यह निष्पादित नहीं होगा।
128
128
129
-
Sometimes it can be handy to temporarily disable a part of code:
129
+
कभी-कभी इस तकनीक का उपयोग करके कोड के एक भाग को अस्थायी रूप से अक्षम करना आसान होता है
130
130
131
131
```js run
132
-
/*Commenting out the code
133
-
alert('Hello');
132
+
/*कोड टिप्पणी की गई है
133
+
alert('हैलो');
134
134
*/
135
-
alert('World');
135
+
alert('विश्व');
136
136
```
137
137
138
138
```smart header="Use hotkeys!"
@@ -152,8 +152,8 @@ alert( 'World' );
152
152
```
153
153
````
154
154
155
-
Please, don't hesitate to comment your code.
155
+
कृपया, अपने कोड में टिप्पणी करने में संकोच न करें।
156
156
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) पर नकारात्मक प्रभाव नहीं पड़ता है।
158
158
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