Skip to content

Commit 991e2ac

Browse files
author
Veljko Pejović
authored
Update article.md
1 parent 45228da commit 991e2ac

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed
Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,86 @@
1-
# The modern mode, "use strict"
1+
# Savremeni mod, "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+
Dugo vremena je JavaScript evoluirao bez problema sa kompatibilnošću. Jeziku su dodate nove funkcije dok se stara funkcionalnost nije promenila.
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+
To je imalo koristi od toga što nikada nije prekršilo postojeći kod. Ali, nedostatak je bio da se bilo kakva greška ili nesavršena odluka koju su doneli JavaScript kreatori zauvek zaglavi u jeziku.
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+
Tako je bilo sve do 2009. godine kada se pojavio ECMAScript 5 (ES5). Jeziku je dodao nove funkcije i modifikovao neke od postojećih. Da bi stari kod radio, većina takvih modifikacija je podrazumevano isključena. Morate ih izričito omogućiti posebnom direktivom: `"use strict"`.
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+
Direktiva izgleda kao string: `"use strict"` ili `'use strict'`. Kada se nalazi na vrhu skripte, ceo skript deluje na "moderan" način.
1212

13-
For example:
13+
Na primjer:
1414

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

18-
// this code works the modern way
18+
// ovaj kod deluje na savremen način
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+
Uskoro ćemo naučiti funkcije (način za grupisanje komandi). Gledajući napred, uzmimo to u obzir `"use strict"` može se staviti na početak tela funkcije umesto celog skripta. To omogućava strogi režim samo u toj funkciji. Ali obično ga ljudi koriste za cijelu skriptu.
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="Obezbijedi da je \"use strict\" na vrhu"
26+
Obavezno proverite da li se „use strict“ nalazi na vrhu vaše skripte, jer u suprotnom strogi režim možda neće biti omogućen.
2727
28-
Strict mode isn't enabled here:
28+
29+
Strogi režim ovde nije omogućen:
2930
3031
```js no-strict
31-
alert("some code");
32-
// "use strict" below is ignored--it must be at the top
32+
alert("neki kod");
33+
// "use strict" ispod se ignoriše-- mora biti na vrhu
3334
3435
"use strict";
3536
36-
// strict mode is not activated
37+
// strogi režim nije omogućen
3738
```
3839
39-
Only comments may appear above `"use strict"`.
40+
Gore se mogu pojaviti samo komentari `"use strict"`.
4041
````
4142

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.
43+
```warn header="Nema načina da otkažete `use strict`"
44+
Ne postoji takva direktiva `"no use strict"` koja vraća motor na staro ponašanje.
4445

45-
Once we enter strict mode, there's no return.
46+
Jednom kada uđemo u strogi režim, nema povratka.
4647
```
4748
48-
## Browser console
49+
## Konzola pregledača
4950
50-
For the future, when you use a browser console to test features, please note that it doesn't `use strict` by default.
51+
Kada za testiranje funkcija koristite konzolu pregledača za ubuduće, imajte na umu da to nema `use strict` podrazumijevano.
5152
52-
Sometimes, when `use strict` makes a difference, you'll get incorrect results.
53+
Ponekad, kada `use strict` čini razliku, dobićete pogrešne rezultate.
5354
54-
You can try to press `key:Shift+Enter` to input multiple lines, and put `use strict` on top, like this:
55+
Možete da pokušate da pritisnete `taster:Shift+Enter` da unesete više redova i stavite „use strict“ na vrh, ovako:
5556
5657
```js
57-
'use strict'; <Shift+Enter for a newline>
58-
// ...your code
59-
<Enter to run>
58+
'use strict'; <Shift+Enter za novi red>
59+
// ...tvoj kod
60+
<Enter za pokretanje>
6061
```
6162

62-
It works in most browsers, namely Firefox and Chrome.
63+
Radi u većini pregledača, naime Firefox i Chrome.
6364

64-
If it doesn't, the most reliable way to ensure `use strict` would be to input the code into console like this:
65+
Ako ne, najpouzdaniji način da to osigurate `use strict` bilo bi da unesete kod u konzolu ovako:
6566

6667
```js
6768
(function() {
6869
'use strict';
6970

70-
// ...your code...
71+
// ...tvoj kod...
7172
})()
7273
```
7374

74-
## Always "use strict"
75+
## Uvjek "use strict"
7576

76-
We have yet to cover the differences between strict mode and the "default" mode.
77+
Moramo još da pokrijemo razlike između strogog načina rada i "uobičajenog" režima.
7778

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.
79+
U sledećim poglavljima, dok učimo jezičke karakteristike, primetićemo razlike između strogog i zadanog načina rada. Srećom, nema ih mnogo i oni nam zapravo poboljšavaju život.
7980

80-
For now, it's enough to know about it in general:
81+
Za sada je dovoljno znati o tome uopšte:
8182

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.
83+
1. `"use strict"` direktiva prebacuje motor u „moderan“ mod, menjajući ponašanje nekih ugrađenih funkcija. Detalje ćemo videti kasnije u vodiču.
84+
2. trogi režim je omogućen postavljanjem `"use strict"` na vrhu skripte ili funkcije. Nekoliko jezičnih funkcija, poput „klase“ i „modula“, automatski omogućuju strogi režim.
85+
3. Strogi režim podržavaju svi moderni pregledači.
86+
4. Preporučujemo uvek pokretanje skripti sa `"use strict"`. Svi primjeri u ovom vodiču pretpostavljaju strogi način rada, osim ako (vrlo rijetko) nije drugačije određeno.

0 commit comments

Comments
 (0)