Skip to content

Commit 712fee8

Browse files
authored
Merge pull request #67 from meilune/master
Translated the use strict mode article
2 parents c8acfd9 + 2d9c2da commit 712fee8

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed
+36-36
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
# The modern mode, "use strict"
1+
# Šiuolaikinis režimas, "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+
Ilgą laiką, JavaScript tobulėjo be jokių problemų dėl suderinamumo. Naujos funkcijos buvo pridedamos nekeičiant senojo funkcionalumo.
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+
Tai buvo naudinga, nes senas jau egzistuojantis kodas galėjo likti nepaveiktas. Tačiau neigiama to pusė yra tai, kad bet kokia klaida ar netobulas sprendimas padarytas JavaScript kūrėjų, užstrigdavo kalboje amžiams.
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+
Taip buvo iki kol 2009 metais atsirado ECMAScript 5 (ES5). Ji pridėjo naujų funkcijų ir patobulino jau egzistuojančias. Kad senasis kodas toliau galėtų veikti, didžioji dalis tokių patobulinimų yra išjunti pagal nutylėjimą. Juos turite aiškiai įgalinti su specialia direktyva: `"use strict"`(vert. naudoti griežtą).
88

99
## "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+
Direktyva atrodo kaip vėrinys (ang. "string"): `"use strict"` arba `'use strict'`. Kai jis rašomas skripto viršuje, visas skriptas leidžiamas "moderniu" būdu.
1212

13-
For example:
13+
Pavyzdžiui:
1414

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

18-
// this code works the modern way
18+
// šis kodas suveiks moderniu būdu
1919
...
2020
```
2121

22-
We will learn functions (a way to group commands) soon. Looking ahead, let's note that `"use strict"` can be put at the beginning of the function body instead of the whole script. Doing that enables strict mode in that function only. But usually, people use it for the whole script.
22+
Mes greitai mokinsimės funkcijas (tam tikras būdas grupuoti komandas), bet užbėgant už akių, galime pažymėti, kad `"use strict"` gali būti dedamas funkcijos pradžioje. Tokiu būdų tik funkcijos korpusas (ang. "body") turi griežtą režimą, o ne visas skriptas. Bet dažniausiai žmonės naudoja šį režimą visame skripte.
2323

2424

25-
````warn header="Ensure that \"use strict\" is at the top"
26-
Please make sure that `"use strict"` is at the top of your scripts, otherwise strict mode may not be enabled.
25+
````warn header="Įsitikinkite, kad \"use strict\" yra viršuje"
26+
Prašau, įsitikinkite, kad `"use strict"` yra jūsų skriptų viršuje, kitu atveju griežtasis režimas gali nesuveikti.
2727
28-
Strict mode isn't enabled here:
28+
Šiuo atveju griežtasis režimas nėra įgalintas:
2929
3030
```js no-strict
31-
alert("some code");
32-
// "use strict" below is ignored--it must be at the top
31+
alert("kažkoks kodas");
32+
// "use strict" esantis apačioje ignoruojamas--jis privalo būti viršuje
3333
3434
"use strict";
3535
36-
// strict mode is not activated
36+
// griežtas režimas neaktyvuotas
3737
```
3838
39-
Only comments may appear above `"use strict"`.
39+
Anksčiau už `"use strict"` gali būti tik komentarai.
4040
````
4141

42-
```warn header="There's no way to cancel `use strict`"
43-
There is no directive like `"no use strict"` that reverts the engine to old behavior.
42+
```warn header="Nėra būdo kaip atšaukti `use strict`"
43+
Nėra tokios direktyvos kaip `"no use strict"`, kuris sugrąžintų sistemą į senąjį funkcionavimą.
4444

45-
Once we enter strict mode, there's no return.
45+
Kai jau įžengiame į griežtą režimą, kelio atgal nebėra.
4646
```
4747
48-
## Browser console
48+
## Naršyklės konsolė
4949
50-
For the future, when you use a browser console to test features, please note that it doesn't `use strict` by default.
50+
Ateičiai, kai naudosite naršyklės konsolės testavimo funkcijas, žinokite, kad ji nenaudoja `use strict` pagal numatytus nustatymus.
5151
52-
Sometimes, when `use strict` makes a difference, you'll get incorrect results.
52+
Kartais, kai `use strict` įtaka yra svarbi, galite gauti neteisingus rezultatus.
5353
54-
You can try to press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, like this:
54+
Norėdami konsolėje suvesti daugiau nei vieną eilutę paspauskite `key:Shift+Enter`, tokiu būdu galite užrašyti `use strict` viršuje, štai taip:
5555
5656
```js
57-
'use strict'; <Shift+Enter for a newline>
58-
// ...your code
59-
<Enter to run>
57+
'use strict'; <Shift+Enter perkels jus į naują eilutę>
58+
// ...
59+
<Paspauskite enter, kad paleistumėte kodą>
6060
```
6161

62-
It works in most browsers, namely Firefox and Chrome.
62+
Tai suveikia didžiojoje dalyje naršyklių, tarp jų Firefox ir Chrome.
6363

64-
If it doesn't, the most reliable way to ensure `use strict` would be to input the code into console like this:
64+
Jeigu nesuveikia, geriausias būdas įsitikinti, kad `use strict` veiks, kai kodas konsolėje paleidžiamas tokiu būdu:
6565

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

70-
// ...your code...
70+
// ...jūsų kodas...
7171
})()
7272
```
7373

74-
## Always "use strict"
74+
## Visada naudokite "use strict"
7575

76-
We have yet to cover the differences between strict mode and the "default" mode.
76+
Dar aptarsime skirtumus tarp griežto režimo ir numatytojo (ang. "default") režimo.
7777

78-
In the next chapters, as we learn language features, we'll note the differences between the strict and default modes. Luckily, there aren't many and they actually make our lives better.
78+
Sekančiuose skyriuose, kai mokinsimės kalbos savybes, pastebėsime skirtumus tarp griežto ir numatyto režimo. Laimei, jų nėra labai daug ir jie iš tikrųjų palengvina mūsų gyvenimus.
7979

80-
For now, it's enough to know about it in general:
80+
Kol kas užtenka žinoti apie tai pagrindinius dalykus:
8181

82-
1. The `"use strict"` directive switches the engine to the "modern" mode, changing the behavior of some built-in features. We'll see the details later in the tutorial.
83-
2. Strict mode is enabled by placing `"use strict"` at the top of a script or function. Several language features, like "classes" and "modules", enable strict mode automatically.
84-
3. Strict mode is supported by all modern browsers.
85-
4. We recommended always starting scripts with `"use strict"`. All examples in this tutorial assume strict mode unless (very rarely) specified otherwise.
82+
1. Naudojant direktyvą `"use strict"` sistema persijungia į "modernų" režimą, pakeisdama kai kurių įmontuotų savybių elgseną. Detaliau apie tai pamatysite vėlesnėse pamokose.
83+
2. Griežtas režimas paleidžiamas užrašant `"use strict"` skripto arba funkcijos viršuje. Kai kurios kalbos savybės, kaip klasės (ang. "classes") ir moduliai (ang. "modules") griežtą režimą paleidžia automatiškai.
84+
3. Griežtą režimą palaiko visos modernios naršyklės.
85+
4. Rekomenduojame visus skriptus pradėti su `"use strict"`. Visi šių pamokų pavyzdžiai numano, kad griežtas režimas yra naudojamas, nebent (labai retais atvejais) yra nurodoma kitaip.

0 commit comments

Comments
 (0)