Skip to content

Commit 43565c1

Browse files
committed
11-logical-operators finish translation for article.md
1 parent aa45929 commit 43565c1

File tree

1 file changed

+24
-26
lines changed
  • 1-js/02-first-steps/11-logical-operators

1 file changed

+24
-26
lines changed

1-js/02-first-steps/11-logical-operators/article.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -202,87 +202,85 @@ alert( null && 5 ); // null
202202
alert( 0 && "orice s-ar întâmpla" ); // 0
203203
```
204204

205-
<!-- We can also pass several values in a row. See how the first falsy one is returned: -->
206-
De asemenea, putem oferi mai multe valori în același timp. Observați cum prima valoare falsy este returnată:
207-
<!-- Mai verifică puțin traducerea de mai sus -->
205+
De asemenea, pot fi folosite mai multe valori simultan. Observați cum prima valoare falsy este returnată:
208206

209207
```js run
210208
alert( 1 && 2 && null && 3 ); // null
211209
```
212210

213-
When all values are truthy, the last value is returned:
211+
Dacă toate valorile sunt truthy, ultima dintre ele este returnată:
214212

215213
```js run
216-
alert( 1 && 2 && 3 ); // 3, the last one
214+
alert( 1 && 2 && 3 ); // 3, ultima
217215
```
218216

219-
````smart header="Precedence of AND `&&` is higher than OR `||`"
220-
The precedence of AND `&&` operator is higher than OR `||`.
217+
````smart header="Prioritatea lui ȘI `&&` este mai mare decât cea a lui ORI `||`"
218+
Prioritatea operatorului ȘI `&&` este mai mare față de ce a lui ORI `||`.
221219

222-
So the code `a && b || c && d` is essentially the same as if the `&&` expressions were in parentheses: `(a && b) || (c && d)`.
220+
Astfel, codul `a && b || c && d` este în esență exact la fel cu folosirea operatorului `&&` între paranteze: `(a && b) || (c && d)`.
223221
````
224222

225-
````warn header="Don't replace `if` with `||` or `&&`"
226-
Sometimes, people use the AND `&&` operator as a "shorter way to write `if`".
223+
````warn header="Nu înlocuiți `if` cu `||` sau `&&`"
224+
Uneori, oamenii folosesc operatorul ȘI `&&` pentru a scrie o formă mai scurtă de `if` statement.
227225

228-
For instance:
226+
De exemplu:
229227

230228
```js run
231229
let x = 1;
232230
233-
(x > 0) && alert( 'Greater than zero!' );
231+
(x > 0) && alert( 'Mai mare decât zero!' );
234232
```
235233

236-
The action in the right part of `&&` would execute only if the evaluation reaches it. That is, only if `(x > 0)` is true.
234+
Alerta din partea dreaptă a lui `&&` ajugne să fie executată doar dacă evaluarea ajunge până la ea. Adică, doar dacă if `(x > 0)` este true.
237235

238-
So we basically have an analogue for:
236+
Astfel echivalentul este:
239237

240238
```js run
241239
let x = 1;
242240
243-
if (x > 0) alert( 'Greater than zero!' );
241+
if (x > 0) alert( 'Mai mare decât zero!' );
244242
```
245243

246-
Although, the variant with `&&` appears shorter, `if` is more obvious and tends to be a little bit more readable. So we recommend using every construct for its purpose: use `if` if we want `if` and use `&&` if we want AND.
244+
Deși, varianta cu `&&` pare a fi mai scurtă, varianta cu `if` statement este mai evidentă și mai ușor de citit. Așa că, recomandarea noastră este ca fiecare construcție să fie folosită pentru propriul scop: folosim `if` dacă vreum un `if` statement și folosit `&&` dacă avem nevoie de operatorul ȘI.
247245
````
248246

249247

250248
## ! (NOT)
251249

252-
The boolean NOT operator is represented with an exclamation sign `!`.
250+
Operatorul boolean NU este reprezentat printrun semn de exclamare.
253251

254-
The syntax is pretty simple:
252+
Sintaxa este destul de simplă:
255253

256254
```js
257255
result = !value;
258256
```
259257

260-
The operator accepts a single argument and does the following:
258+
Operatorul acceptă un singur argument și face umrătoarele lucruri:
261259

262-
1. Converts the operand to boolean type: `true/false`.
263-
2. Returns the inverse value.
260+
1. Convertește operantul într-un boolean de tipul: `true/false`.
261+
2. Returnează valoarea opusă.
264262

265-
For instance:
263+
Spre exemplu:
266264

267265
```js run
268266
alert( !true ); // false
269267
alert( !0 ); // true
270268
```
271269

272-
A double NOT `!!` is sometimes used for converting a value to boolean type:
270+
Dublu NU `!!` poate fi folosit uneori pentru a converti o valoare într-un boolean.
273271

274272
```js run
275273
alert( !!"non-empty string" ); // true
276274
alert( !!null ); // false
277275
```
278276

279-
That is, the first NOT converts the value to boolean and returns the inverse, and the second NOT inverses it again. In the end, we have a plain value-to-boolean conversion.
277+
Adică, primul NU convertește valoare într-un boolean și returnează valoarea opusă, iar cel de al doilea NU inversează valoarea din nou. În final, obținem o conversie de la o valoare la un boolean.
280278

281-
There's a little more verbose way to do the same thing -- a built-in `Boolean` function:
279+
Există o metodă special concepută pentru acest lucru -- o funcție `Boolean` concepută expres pentru acesastă necesitate.
282280

283281
```js run
284282
alert( Boolean("non-empty string") ); // true
285283
alert( Boolean(null) ); // false
286284
```
287285

288-
The precedence of NOT `!` is the highest of all logical operators, so it always executes first, before `&&` or `||`.
286+
Prioritatea lui NU `!` este cea mai mare dintre toți operatorii logici, fiind executat mereu primul, înaintea lui `&&` sau `||`.

0 commit comments

Comments
 (0)