Skip to content

Commit 27a3964

Browse files
Merge pull request #73 from bugron/translation/03-strict-mode
The modern mode, "use strict"
2 parents 24688ec + c8865f8 commit 27a3964

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed
+32-36
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,85 @@
1-
# The modern mode, "use strict"
1+
# "use strict"
22

3-
For a long time, JavaScript evolved without compatibility issues. New features were added to the language while old functionality didn't change.
3+
Երկար ժամանակ JavaScript–ը զարգանում էր առանց համատեղելիության խնդիրների։ Լեզվում նոր հնարավորություններ էին ավելացվում, իսկ հները փոփոխության չէին ենթարկվում։
44

5-
That had the benefit of never breaking existing code. But the downside was that any mistake or an imperfect decision made by JavaScript's creators got stuck in the language forever.
5+
Այս մոտեցման առավելությունն այն էր, որ գոյություն ունեցող կոդը միշտ աշխատում էր առանց փոփոխության։ Մյուս կողմից, JavaScript–ը նախագծողների ցանկացած սխալը, կամ թերի որոշումը դատապարտված էր մնալ լեզվում ընդմիշտ։
66

7-
This was the case until 2009 when ECMAScript 5 (ES5) appeared. It added new features to the language and modified some of the existing ones. To keep the old code working, most such modifications are off by default. You need to explicitly enable them with a special directive: `"use strict"`.
7+
Սա ճիշտ էր մինչև 2009 թ․, երբ հայտնվեց ECMAScript 5–ը (ES5)։ Այն լեզվում ավելացրեց նոր հնարավորություններ և փոփոխեց որոշ արդեն գոյություն ունեցողները։ Որպեսզի հին կոդն աշխատեր, այդ փոփոխությունները անջատած էին լռելյայն։ Դրանք պետք էր բացահայտ միացնել, օգատգործելով հատուկ հրահանգ՝ `"use strict"`։
88

9-
## "use strict"
9+
## "use strict" հրահանգը
1010

11-
The directive looks like a string: `"use strict"` or `'use strict'`. When it is located at the top of a script, the whole script works the "modern" way.
11+
Այս հրահանգն իրենից ներկայացնում է սովորական տող՝ `"use strict"`, կամ `'use strict'`։ Երբ այն գտնվում է սկրիպտի վերևում, ապա սկրիպն աշխատում է ժամանակակից ձևով։
1212

13-
For example:
13+
Օրինակ՝
1414

1515
```js
1616
"use strict";
1717

18-
// this code works the modern way
18+
// այս կոդն աշխատում է ժամանակակից ձևով
1919
...
2020
```
2121

22-
Quite soon we're going to learn functions (a way to group commands), so let's note in advance that `"use strict"` can be put at the beginning of a function. Doing that enables strict mode in that function only. But usually people use it for the whole script.
22+
Շուտով սովորելու ենք ֆունկցիաների մասին, այնպես որ նախօրոք ասենք, որ `"use strict"`–ը կարելի է տեղադրել ֆունկցիայի սկզբում։ Դա միացնում է ժամանակակից ռեժիմը միայն այդ ֆունկցիայում։ Սովորաբար `"use strict"`–ն օգտագործվում է ողջ սկրիպտի համար։
2323

24-
````warn header="Ensure that \"use strict\" is at the top"
25-
Please make sure that `"use strict"` is at the top of your scripts, otherwise strict mode may not be enabled.
24+
````warn header="Համոզվեք, որ \"use strict\"–ը գտվում է վերևում"
25+
Համոզվեք, որ `"use strict"`–ը գտվում է սկրիպտի վերևում, հակառակ դեպքում այն կարող է չաշխատել։
2626
27-
Strict mode isn't enabled here:
27+
Այս օրինակում այն չի աշխատում՝
2828
2929
```js no-strict
3030
alert("some code");
31-
// "use strict" below is ignored--it must be at the top
31+
// "use strict"–ն այստեղ արհամարհվում է՝ այն պետք է գտնվի ամենավերևում
3232
3333
"use strict";
3434
35-
// strict mode is not activated
35+
// ժամանակակից ռեժիմը միացված չէ
3636
```
3737
38-
Only comments may appear above `"use strict"`.
38+
`"use strict"`–ից առաջ կարող են լինել միայն մեկնաբանություններ՝
3939
````
4040

41-
```warn header="There's no way to cancel `use strict`"
42-
There is no directive like `"no use strict"` that reverts the engine to old behavior.
41+
```warn header="Հնարավոր չէ չեղարկել `use strict`–ի գործողությունը"
42+
Գոյություն չունի `"no use strict"` հրահանգ, որը չեղարկում է շարժիչի պահվածքը։
4343

44-
Once we enter strict mode, there's no going back.
44+
Այսպիսով՝ `use strict`–ի գործողությունը չի կարելի չեղարկել։
4545
```
4646
47-
## Browser console
47+
## Զննիչի բարձակը (browser console)
4848
49-
When you use a [developer console](info:devtools) to run code, please note that it doesn't `use strict` by default.
49+
[Ծրագրավորման բարձակ](info:devtools)–ում `use strict`–ը լռելյայն չի օգտագործում։
5050
51-
Sometimes, when `use strict` makes a difference, you'll get incorrect results.
51+
Երբեմն `use strict`–ի կիրառումը կարող է հանգեցնել սխալ արդյունքների։
5252
53-
So, how to actually `use strict` in the console?
53+
Ունեմն ինչպե՞ս օգտագործել `use strict`–ը բարձակում։
5454
55-
First, you can try to press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, like this:
55+
Կարող եք սեղմել `key:Shift+Enter` ստեղները մի քանի տող ներմուծելու համար և գրել `use strict` վերևում՝
5656
5757
```js
5858
'use strict'; <Shift+Enter for a newline>
5959
// ...your code
6060
<Enter to run>
6161
```
6262

63-
It works in most browsers, namely Firefox and Chrome.
63+
Սա կաշխատի հիմնական զննիչներում (Firefox, Chrome
6464

65-
If it doesn't, e.g. in an old browser, there's an ugly, but reliable way to ensure `use strict`. Put it inside this kind of wrapper:
65+
Եթե օգտագործում եք շատ հին զննիչ, ապա կարելի է `use strict`–ը դնել ֆունկցիայի մեջ՝
6666

6767
```js
6868
(function() {
6969
'use strict';
7070

71-
// ...your code here...
71+
// ...ձեր կոդն այստեղ...
7272
})()
7373
```
7474

75-
## Should we "use strict"?
75+
## Արդյոք պե՞տք է օգտագործել "use strict" հրահանգը
7676

77-
The question may sound obvious, but it's not so.
77+
Պատասխանը կարող է ակնհայտ թվալ, բայց դա այդպես չէ։
7878

79-
One could recommend to start scripts with `"use strict"`... But you know what's cool?
79+
Գուցե ինչ–որ մեկը խորդուրդ տա սկսել բոլոր սկրիպտերը `"use strict"`–ով։ Սակայն, ժամանակակից JavaScript–ի «class»–երը և «module»–ները (որոնք մենք հետո կուսումնասիրենք), օգտագործում են `use strict`–ը լռելյայն։ Այնպես որ կարիք չկա օգտագործել `"use strict"` հրահանգը այդ դեպքերում։
8080

81-
Modern JavaScript supports "classes" and "modules" - advanced language structures (we'll surely get to them), that enable `use strict` automatically. So we don't need to add the `"use strict"` directive, if we use them.
81+
**Այսպիսով՝ մենք կօգտագործենք `"use strict";`–ի մեր սկրիպտերում։ Հետո, երբ ձեր կոդն ամբողջովին կգտնվի «class»–երում և «module»–ներում՝ կարող եք այն բաց թողել։**
8282

83-
**So, for now `"use strict";` is a welcome guest at the top of your scripts. Later, when your code is all in classes and modules, you may omit it.**
83+
Հաջորդ բաժիններում, որտեղ կսովորենք լեզվի այլ հնարավորությունների մասին, կտեսնենք տարբերությունը `"use strict"`–ով և առանց դրա։
8484

85-
As of now, we've got to know about `use strict` in general.
86-
87-
In the next chapters, as we learn language features, we'll see the differences between the strict and old modes. Luckily, there aren't many and they actually make our lives better.
88-
89-
All examples in this tutorial assume strict mode unless (very rarely) specified otherwise.
85+
Այս ձեռնարկի բոլոր օրինակները ենթադրում են `"use strict"`–ի կիրառում, եթե հակառակը նշված չէ (խիստ հազվադեպ դեպքերում)։

0 commit comments

Comments
 (0)