Skip to content

Commit f3b44db

Browse files
authored
Merge pull request #15 from JustIzumi/JustIzumi-strict-mode
The modern mode, "use strict"
2 parents b127c86 + c42e5fc commit f3b44db

File tree

2 files changed

+37
-101
lines changed

2 files changed

+37
-101
lines changed

1-js/01-getting-started/4-devtools/article.md

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,88 @@
1-
# The modern mode, "use strict"
1+
# Modern üzemmód, "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+
A JavaScript hosszú ideig kompatibilitási nehézségek nélkül fejlődött. A nyelv új elemekkel bővült, a meglévőek pedig változatlanok voltak.
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+
A nyelv újabb verziói így kompatibilisek maradtak a korábban írt programokkal, cserébe viszont együtt kellett élni a nyelv tervezésekor hozott rossz döntésekkel.
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+
Ez volt a tényállás, mígnem 2009-ben megjelent az ECMAScript 5 (ES5), amely nem csak bővítette a nyelvet, hanem néhol meg is változtatta a működését. Annak érdekében, hogy ezek a változások ne okozzanak gondot a régebben írt programokban, e változtatások alapértelmezetten ki vannak kapcsolva, az engedélyezésükhöz pedig egy speciális "use strict" diektívát kell elhelyezni a kódban.
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+
Ez a direktíva ránézésre egy átlagos szöveg (string): "use strict", vagy 'use strict'. A szkript tetejére helyezve azonban arra utasítja a JS motort, hogy a szkriptet modern üzemmódban futtassa.
1212

13-
For example:
13+
Példa:
1414

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

18-
// this code works the modern way
18+
// a kód modern üzemmódban fog működni
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+
Hamarosan szó lesz a függvényekről (JS parancsok csoportosításának egy módja). Elöljáróban elég annyit megjegyeznünk, hogy a "use strict" egy függvény elején elhelyezve csak az adott függvényen belül engedélyezi a modern üzemmódot. Általában azonban az egész szkriptre szokták használni a "use strict"-et.
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="Győződj meg róla, hogy a \"use strict\" mindig a szkript tetején van!"
25+
Fontos, hogy a `"use strict"` **mindig** a szkript elején legyen, különben a modern mód nem lesz bekapcsolva.
2626
27-
Strict mode isn't enabled here:
27+
Ebben a példában a `"use strict" hibás elhelyezkedése miatt a modern mód nem lesz bekapcsolva`:
2828
2929
```js no-strict
30-
alert("some code");
31-
// "use strict" below is ignored--it must be at the top
32-
30+
alert("valami");
31+
// az alábbi "use strict" érvénytelen -- a szkript legtetején kell elhelyezni
3332
"use strict";
3433
35-
// strict mode is not activated
34+
// a strict üzemmód nincs engedélyezve
3635
```
3736
38-
Only comments may appear above `"use strict"`.
37+
A `"use strict"` felé csak kommenteket szabad tenni.
3938
````
4039

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.
40+
```warn header="A `use strict`-et nem lehet utólag kikapcsolni"
41+
Nincsen olyan direktíva, mint például egy "no use strict", ami visszaállítaná a motort az alapértelmezett üzemmódra.
4342

44-
Once we enter strict mode, there's no going back.
43+
Ha egyszer bekapcsoltuk a strict üzemmódot, nincs visszaút.
4544
```
4645
47-
## Browser console
46+
## Használat a böngésző konzolban
4847
49-
When you use a [developer console](info:devtools) to run code, please note that it doesn't `use strict` by default.
48+
Ha a [fejlesztői konzolt](info:devtools) használod kód futtatására, fontos tudni, hogy alapértelmezetten nem strict üzemmódot használ.
5049
51-
Sometimes, when `use strict` makes a difference, you'll get incorrect results.
50+
Bizonyos esetekben a "use strict" használatával nem várt eredményeket kaphatunk.
5251
53-
So, how to actually `use strict` in the console?
52+
De egyáltalán hogyan használjuk a use strict-et a konzolban?
5453
55-
First, you can try to press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, like this:
54+
Először próbáljuk meg a Shift+Enter gombok lenyomásával több sorba írni a kódot, majd a legelejére odatenni a use strict-et. Valahogy így:
5655
5756
```js
58-
'use strict'; <Shift+Enter for a newline>
59-
// ...your code
60-
<Enter to run>
57+
'use strict'; <Shift+Enter, hogy új sort kezdjünk>
58+
// ...a kódod
59+
<Nyomjunk entert a futtatáshoz>
6160
```
6261

63-
It works in most browsers, namely Firefox and Chrome.
62+
Ez a legtöbb böngészőben (mint például a Chrome vagy a Firefox) működik.
6463

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:
64+
Ha ez nem működne (például régi böngészőben), akkor egy megbízható megoldás az alábbi konstrukció használata:
6665

6766
```js
6867
(function() {
6968
'use strict';
7069

71-
// ...your code here...
70+
// ...a futtatandó kódunk...
7271
})()
7372
```
7473

75-
## Should we "use strict"?
74+
## Használjuk-e a "use strict"-et?
7675

77-
The question may sound obvious, but it's not so.
76+
Habár a kérdés egyértelműnek hangzik, nem az.
7877

79-
One could recommend to start scripts with `"use strict"`... But you know what's cool?
78+
Okkal gondolhatnánk, hogy mindig érdemes használni a "use strict"-et, de erre nincs szükség.
8079

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.
80+
A modern JavaScript egyes nyelvi elemei, mint az osztály (class) és a modul (module) - ezeket később részletezzük - alapértelmezetten strict üzemmódban futnak, így ezeknek a nyelvi elemeknek a használatakor a "use strict" elhagyható.
8281

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.**
82+
**Egyelőre jó, ha használjuk a "use strict"-et, de később, amikor a kódunk modulokból és osztályokból áll, elhagyhatjuk.**
8483

85-
As of now, we've got to know about `use strict` in general.
84+
Jelenleg, az alapok miatt jó tudni a `use strict` létezéséről.
8685

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.
86+
A következő fejezetekben tanulunk majd egy kicsit a nyelvi funckiókról és az új és régi módok közti különbségekről. Szerencsénkre az utóbbiakból nincsen sok, és azok amik vannak azok is csak a mi dolgunkat fogják könnyíteni.
8887

89-
All examples in this tutorial assume strict mode unless (very rarely) specified otherwise.
88+
Az ebben a fejezetben lévő példák, ha nincs másként feltüntetve, strict üzemmódot feltételeznek.

0 commit comments

Comments
 (0)