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/05-types/article.md
+35-35Lines changed: 35 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,86 +1,86 @@
1
-
# Data types
1
+
# Tipovi podataka
2
2
3
-
A variable in JavaScript can contain any data. A variable can at one moment be a string and at another be a number:
3
+
Varijabla u JavaScript-i može da sadrži bilo koje podatke. Varijabla u jednom trenutku može biti string, a u drugom broj:
4
4
5
5
```js
6
-
//no error
6
+
//nema greške
7
7
let message ="hello";
8
8
message =123456;
9
9
```
10
10
11
-
Programming languages that allow such things are called "dynamically typed", meaning that there are data types, but variables are not bound to any of them.
11
+
Programski jezici koji dopuštaju takve stvari nazivaju se „dinamički kucano“, što znači da postoje tipovi podataka, ali varijable nisu vezane ni za jedan od njih.
12
12
13
-
There are seven basic data types in JavaScript. Here, we'll cover them in general and in the next chapters we'll talk about each of them in detail.
13
+
Postoji sedam osnovnih tipova podataka u JavaScript-u. Ovde ćemo ih pokriti generalno, a u narednim ćemo poglavljima detaljno govoriti o svakom od njih.
14
14
15
-
## A number
15
+
## Broj
16
16
17
17
```js
18
18
let n =123;
19
19
n =12.345;
20
20
```
21
21
22
-
The *number* type represents both integer and floating point numbers.
22
+
Tip *broj* predstavlja brojeve i brojeve sa pomičnim zarezom.
23
23
24
-
There are many operations for numbers, e.g. multiplication`*`, division`/`, addition`+`, subtraction`-`, and so on.
24
+
Postoji mnogo operacija za brojeve, npr. množenje`*`, dijeljenje`/`, sabiranje`+`, oduzimanje`-`, itd.
25
25
26
-
Besides regular numbers, there are so-called "special numeric values" which also belong to this data type: `Infinity`, `-Infinity`and`NaN`.
26
+
Pored regularnih brojeva, postoje i takozvane "posebne numeričke vrednosti" koje takođe pripadaju ovom tipu podataka: `Infinity`, `-Infinity`i`NaN`.
27
27
28
-
-`Infinity`represents the mathematical [Infinity](https://en.wikipedia.org/wiki/Infinity) ∞. It is a special value that's greater than any number.
28
+
-`Infinity`predstavlja matematičku [beskonačnost](https://en.wikipedia.org/wiki/Infinity) ∞. To je posebna vrednost veća od bilo kog broja.
29
29
30
-
We can get it as a result of division by zero:
30
+
To možemo dobiti kao rezultat podjele na nulu:
31
31
32
32
```js run
33
33
alert( 1/0 ); // Infinity
34
34
```
35
35
36
-
Or just reference it directly:
36
+
Ili direktnim navođenjem:
37
37
38
38
```js run
39
39
alert( Infinity ); // Infinity
40
40
```
41
-
-`NaN`represents a computational error. It is a result of an incorrect or an undefined mathematical operation, for instance:
41
+
-`NaN`predstavlja grešku u računanju. Na primjer, rezultat je pogrešne ili nedefinisane matematičke operacije:
42
42
43
43
```js run
44
44
alert( "not a number" / 2 ); // NaN, such division is erroneous
45
45
```
46
46
47
-
`NaN`is sticky. Any further operation on`NaN`returns`NaN`:
47
+
`NaN`je ljepljiv. Svako sledeća operacija na`NaN`vraća`NaN`:
48
48
49
49
```js run
50
50
alert( "not a number" / 2 + 5 ); // NaN
51
51
```
52
52
53
-
So, if there's a `NaN` somewhere in a mathematical expression, it propagates to the whole result.
53
+
Dakle, ako negde u matematičkom izrazu postoji `NaN`, on se širi ka celokupnom rezultatu.
54
54
55
-
```smart header="Mathematical operations are safe"
56
-
Doing maths is "safe" in JavaScript. We can do anything: divide by zero, treat non-numeric strings as numbers, etc.
55
+
```smart header="Matematičke operacije su sigurne"
56
+
Bavljenje matematikom je u JavaScriptu sigurno. Možemo učiniti bilo šta: podeliti na nulu, tretirati ne numeričke nizove kao brojeve itd.
57
57
58
-
The script will never stop with a fatal error ("die"). At worst, we'll get`NaN`as the result.
58
+
Skripta nikada neće prestati sa fatalnom greškom ("umreti"). U najgorem slučaju dobićemo`NaN`kao rezultat.
59
59
```
60
60
61
-
Special numeric values formally belong to the "number" type. Of course they are not numbers in the common sense of this word.
61
+
Posebne numeričke vrednosti formalno pripadaju vrsti „broj“. Naravno da to nisu brojevi u zdravom smislu ove reči.
62
62
63
-
We'll see more about working with numbers in the chapter<info:number>.
63
+
Više ćemo videti o radu sa brojevima u ovom poglavlju<info:number>.
64
64
65
-
## A string
65
+
## String
66
66
67
-
A string in JavaScript must be surrounded by quotes.
67
+
String u JavaScript moraju biti između znakova navodnika.
Double and single quotes are "simple" quotes. There's no difference between them in JavaScript.
81
+
Dupli i pojedinačni navodnici su "jednostavni"citati. Nema razlike među njima u JavaScript-u.
82
82
83
-
Backticks are "extended functionality" quotes. They allow us to embed variables and expressions into a string by wrapping them in `${…}`, for example:
83
+
Zatvoreni jednostruki navodnici su navodnici "proširene funkcionalnosti". Omogućuju nam da uklopimo varijable i izraze u niz omotajući ih, na primer, „$ {…}“
alert( `the result is *!*${1+2}*/!*` ); // the result is 3
93
93
```
94
94
95
-
The expression inside `${…}`is evaluated and the result becomes a part of the string. We can put anything in there: a variable like `name` or an arithmetical expression like `1 + 2` or something more complex.
95
+
Ekspresija unutar `$ {...}`se procjenjuje i rezultat postaje deo niza. Tamo možemo staviti bilo šta: varijablu poput „name“ ili aritmetički izraz poput „1 + 2“ ili nešto složenije.
96
96
97
-
Please note that this can only be done in backticks. Other quotes don't have this embedding functionality!
97
+
Imajte na umu da se to može učiniti samo jednostrukom navodnicima. Ostale ponude nemaju ovu funkciju ugradnje!
98
98
```js run
99
-
alert( "the result is ${1 + 2}" ); //the result is ${1 + 2} (double quotes do nothing)
99
+
alert( "Rezultat je ${1 + 2}" ); //Rezultat je ${1 + 2} (Dupli navodnici ne rade ništa)
100
100
```
101
101
102
-
We'll cover strings more thoroughly in the chapter<info:string>.
102
+
Detaljnije ćemo prikazati stringove u ovom poglavlju<info:string>.
103
103
104
-
```smart header="There is no *character* type."
105
-
In some languages, there is a special "character" type for a single character. For example, in the C language and in Java it is `char`.
104
+
```smart header="Nema tip *karaktera*."
105
+
U nekim jezicima postoji poseban tip „karaktera“ za jedan karakter. Na primjer, na jeziku C i na Javi to je `char`.
106
106
107
-
In JavaScript, there is no such type. There's only one type: `string`. A string may consist of only one character or many of them.
107
+
U JavaScript-u ne postoji takva vrsta. Postoji samo jedna vrsta: `string`. String se može sastojati od samo jednog znaka ili više njih.
0 commit comments