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/07-operators/article.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -369,21 +369,21 @@ Lista operatorilor:
369
369
- ZERO-FILL RIGHT SHIFT ( `>>>` )
370
370
371
371
372
-
These operators are used very rarely. To understand them, we should delve into low-level number representation, and it would not be optimal to do that right now. Especially because we won't need them any time soon. If you're curious, you can read the [Bitwise Operators](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators) article in MDN. It would be more practical to do that when a real need arises.
372
+
Acești operatori sunt folosiți foarte rar. Pentru a-i înțelege ar trebui să săpăm în reprezentarea numerelor low-level, dar nu ar fi optim să facem asta acum. În special pentru că nu vom avea nevoie de ei foarte curând. Dacă ești curios poți citi articolul din MDN despre [Operatorii pe biți](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators). Ar fi mult mai practic să facem acest lucru când se ivește nevoia.
373
373
374
-
## Modify-in-place
374
+
## Modificarea în-loc
375
375
376
-
We often need to apply an operator to a variable and store the new result in it.
376
+
Deseori trebuie să aplicăm un operator unei variabile și să stocăm noul rezultat în aceasta.
377
377
378
-
For example:
378
+
Spre exemplu:
379
379
380
380
```js
381
381
let n = 2;
382
382
n = n + 5;
383
383
n = n * 2;
384
384
```
385
385
386
-
This notation can be shortened using operators `+=` and `*=`:
386
+
Această notație poate fi scurtată folosind operatorii `+=` și `*=`:
387
387
388
388
```js run
389
389
let n = 2;
@@ -393,9 +393,9 @@ n *= 2; // now n = 14 (same as n = n * 2)
393
393
alert( n ); // 14
394
394
```
395
395
396
-
Short "modify-and-assign" operators exist for all arithmetical and bitwise operators: `/=`, `-=` etc.
396
+
Operatorii scurți "modifică-și-asignează" există pentru toți operatorii aritmetici și pe biți: `/=`, `-=` etc.
397
397
398
-
Such operators have the same precedence as a normal assignment, so they run after most other calculations:
398
+
Asemenea operatori au aceeași precedență precum o asignare normală, așadar ei rulează după majoritatea altor calcule:
399
399
400
400
```js run
401
401
let n = 2;
@@ -405,13 +405,13 @@ n *= 3 + 5;
405
405
alert( n ); // 16 (right part evaluated first, same as n *= 8)
406
406
```
407
407
408
-
## Comma
408
+
## Virgula
409
409
410
-
The comma operator `,` is one of most rare and unusual operators. Sometimes it's used to write shorter code, so we need to know it in order to understand what's going on.
410
+
Operatorul virgulă `,` este unul dintre cei mai rari și mai neobișnuiți operatori. Câteodată este folosit pentru a scrie cod mai scurt, așadar trebuie să îl știm pentru a înțelege ce se petrece.
411
411
412
-
The comma operator allows us to evaluate several expressions, dividing them with a comma `,`. Each of them is evaluated, but the result of only the last one is returned.
412
+
Operatorul virgulă permite ne permite să evaluăm câteva expresii, să le împărțim cu o virgulă `,`. Fiecare dintre ele este evaluată, dar doar rezultatul ultimei este returnată.
413
413
414
-
For example:
414
+
De exemplu:
415
415
416
416
```js run
417
417
*!*
@@ -421,19 +421,19 @@ let a = (1 + 2, 3 + 4);
421
421
alert( a ); // 7 (the result of 3 + 4)
422
422
```
423
423
424
-
Here, the first expression `1 + 2` is evaluated, and its result is thrown away, then `3 + 4` is evaluated and returned as the result.
424
+
Aici, prima expresie `1 + 2` este evaluată și rezultatul ei este aruncat, apoi `3 + 4` este evaluat și returnat ca și rezultat.
425
425
426
426
```smart header="Comma has a very low precedence"
427
-
Please note that the comma operator has very low precedence, lower than `=`, so parentheses are important in the example above.
427
+
Te rog observă că operatorul virgulp are precedență foarte mică, mai mică chiar decât `=`, așadar parantezele sunt importante în exemplul de mai sus.
428
428
429
-
Without them: `a = 1 + 2, 3 + 4` evaluates `+` first, summing the numbers into `a = 3, 7`, then the assignment operator `=` assigns `a = 3`, and then the number after the comma `7` is not processed anyhow, so it's ignored.
429
+
Fără ele: `a = 1 + 2, 3 + 4` evaluează `+` prima dată, adunând numerele în `a = 3, 7`, apoi operatorul de asignare `=` atribuie `a = 3`, și apoi numărul de după virgulă `7` nu este nicicum procesat, așa că este ignorat.
430
430
```
431
431
432
-
Why do we need such an operator which throws away everything except the last part?
432
+
De ce avem nevoie de un astfel de operator care aruncă tot cu excepția ultimei părți?
433
433
434
-
Sometimes people use it in more complex constructs to put several actions in one line.
434
+
Câteodată lumea îl folosește în construcții mai complexe pentru a pune mai multe acțiuni într-o singură linie.
435
435
436
-
For example:
436
+
De exemplu:
437
437
438
438
```js
439
439
// three operations in one line
@@ -442,4 +442,4 @@ for (*!*a = 1, b = 3, c = a * b*/!*; a < 10; a++) {
442
442
}
443
443
```
444
444
445
-
Such tricks are used in many JavaScript frameworks, that's why we mention them. But usually they don't improve the code readability, so we should think well before writing like that.
445
+
Astfel de trucuri sunt folosite în multe framework-uri JavaScript, de aceea le menționăm aici. Dar în mod normal nu îmbunătățesc lizibilitatea, așa că ar trebui să ne gândim bine înainte de a scrie astfel.
0 commit comments