Skip to content

Commit 58e808f

Browse files
authored
Translated Type Conversion article.md
1 parent 47830a4 commit 58e808f

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

1-js/02-first-steps/06-type-conversions/article.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,30 @@ alert( Number(false) ); // 0
8282
Atkreipkite dėmesį, kad `null` ir `undefined` elgiasi kitaip šiuo atveju: `null` tampa nuliu kai `undefined` tampa `NaN`.
8383

8484
````smart header="Sudėtis '+' sujungia eilutes"
85-
Beveik visos matematinės operacijos paverčia vertes numeriais. A notable exception is addition `+`. If one of the added values is a string, the other one is also converted to a string.
85+
Beveik visos matematinės operacijos paverčia vertes numeriais. Svarbi išimtis yra sudėtis `+`. Jeigu viena iš verčių yra eilutės, kita taip pat paverčiama eilute.
8686
87-
Then, it concatenates (joins) them:
87+
Tada ji sujungia (ang. concatenates) vertes:
8888
8989
```js run
90-
alert( 1 + '2' ); // '12' (string to the right)
91-
alert( '1' + 2 ); // '12' (string to the left)
90+
alert( 1 + '2' ); // '12' (eilutė iš dešinės)
91+
alert( '1' + 2 ); // '12' (eilutė iš kairės)
9292
```
9393
94-
This only happens when at least one of the arguments is a string. Otherwise, values are converted to numbers.
94+
Taip įvyksta tik tokiu atveju kai vienas iš argumentų yra eilutė. Kitu atveju vertės konvertuojamos į skaičius.
9595
````
9696

97-
## Boolean Conversion
97+
## Loginės konversijos
9898

99-
Boolean conversion is the simplest one.
99+
Loginės konversijos yra pačios paprasčiausios.
100100

101-
It happens in logical operations (later we'll meet condition tests and other similar things) but can also be performed explicitly with a call to `Boolean(value)`.
101+
Jos nutinka loginėse operacijose (vėliau dar matysime padėties testus, ang. condition tests, ir panašius atvejus), bet taip pat gali būti atliekamos akivaizdžiam `Boolean(value)` iškvietimui.
102102

103-
The conversion rule:
103+
Konversijos taisyklės:
104104

105-
- Values that are intuitively "empty", like `0`, an empty string, `null`, `undefined`, and `NaN`, become `false`.
106-
- Other values become `true`.
105+
- Vertės kurios intuityviai yra tuščios, kaip `0`, tuščia eilutė, `null`, `undefined` ir `NaN`, tampa `false`.
106+
- Kitos vertės tampa `true`.
107107

108-
For instance:
108+
Pavyzdžiui:
109109

110110
```js run
111111
alert( Boolean(1) ); // true
@@ -115,45 +115,45 @@ alert( Boolean("hello") ); // true
115115
alert( Boolean("") ); // false
116116
```
117117

118-
````warn header="Please note: the string with zero `\"0\"` is `true`"
119-
Some languages (namely PHP) treat `"0"` as `false`. But in JavaScript, a non-empty string is always `true`.
118+
````warn header="Atkreipkite dėmesė: eilutė su nuliu `\"0\"` yra `true`"
119+
Kai kurios kalbos (pavyzdžiui PHP) `"0"` laiko `false`. Bet JavaScript netuščia eilutė visada bus `true`.
120120

121121
```js run
122122
alert( Boolean("0") ); // true
123-
alert( Boolean(" ") ); // spaces, also true (any non-empty string is true)
123+
alert( Boolean(" ") ); // tarpai, taip pat tinka (bet kokia netuščia eilutė yra tinkama - true)
124124
```
125125
````
126126
127-
## Summary
127+
## Santrauka
128128
129-
The three most widely used type conversions are to string, to number, and to boolean.
129+
Trys labiausiai naudojamos tipų konversijos yra į eilutę, skaičių ir loginiai.
130130
131-
**`String Conversion`** -- Occurs when we output something. Can be performed with `String(value)`. The conversion to string is usually obvious for primitive values.
131+
**`Eilutės Konversija`** -- Nutinka kai mes kažką gauname. Gali būti atliekama su `String(value)`. Konversija į eilutę su primityviais tipais dažniausiai yra akivaizdi.
132132
133-
**`Numeric Conversion`** -- Occurs in math operations. Can be performed with `Number(value)`.
133+
**`Skaičių Konversija`** -- Nutinka matematinėse operacijos. Gali būti atliekama su `Number(value)`.
134134
135-
The conversion follows the rules:
135+
Konversija laikosi taisyklių:
136136
137-
| Value | Becomes... |
137+
| Vertė | Tampa... |
138138
|-------|-------------|
139139
|`undefined`|`NaN`|
140140
|`null`|`0`|
141141
|<code>true&nbsp;/&nbsp;false</code> | `1 / 0` |
142-
| `string` | The string is read "as is", whitespaces from both sides are ignored. An empty string becomes `0`. An error gives `NaN`. |
142+
| `string` | Eilutė skaitoma taip kaip yra, tarpai iš abiejų pusių ignoruojami. Tuščia eilutė tampa `0`. Klaida grąžina `NaN`. |
143143
144-
**`Boolean Conversion`** -- Occurs in logical operations. Can be performed with `Boolean(value)`.
144+
**`Loginės Konversijos`** -- Nutinka loginėse operacijose. Gali būti atliekama su `Boolean(value)`.
145145
146-
Follows the rules:
146+
Laikosi taisyklių:
147147
148-
| Value | Becomes... |
148+
| Vertė | Tampa... |
149149
|-------|-------------|
150150
|`0`, `null`, `undefined`, `NaN`, `""` |`false`|
151-
|any other value| `true` |
151+
|bet kokia kita vertė| `true` |
152152
153153
154-
Most of these rules are easy to understand and memorize. The notable exceptions where people usually make mistakes are:
154+
Didžiąją dalį šių taisyklių lengva suprasti ir prisiminti. Svarbios išimtys kur žmonės daro klaidas yra:
155155
156-
- `undefined` is `NaN` as a number, not `0`.
157-
- `"0"` and space-only strings like `" "` are true as a boolean.
156+
- `undefined` kaip skaičius yra `NaN` kaip skaičius, ne `0`.
157+
- `"0"` ir eilutė tik su tarpu kaip `" "` yra tiesa loginėse vertėse.
158158
159-
Objects aren't covered here. We'll return to them later in the chapter <info:object-toprimitive> that is devoted exclusively to objects after we learn more basic things about JavaScript.
159+
Objektai čia neaptariami. Prie jų sugrįšime vėliau skyriuje <info:object-toprimitive>, kuris yra skirtas išskirtinai objektams kai tik sužinosime daugiau apie JavaScript.

0 commit comments

Comments
 (0)