Skip to content

Commit 2e489af

Browse files
committed
1-js/02-first-steps/07-operators
1 parent cd7acf7 commit 2e489af

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

1-js/02-first-steps/07-operators/article.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -369,21 +369,21 @@ Lista operatorilor:
369369
- ZERO-FILL RIGHT SHIFT ( `>>>` )
370370
371371
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.
373373
374-
## Modify-in-place
374+
## Modificarea în-loc
375375
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.
377377
378-
For example:
378+
Spre exemplu:
379379
380380
```js
381381
let n = 2;
382382
n = n + 5;
383383
n = n * 2;
384384
```
385385
386-
This notation can be shortened using operators `+=` and `*=`:
386+
Această notație poate fi scurtată folosind operatorii `+=` și `*=`:
387387
388388
```js run
389389
let n = 2;
@@ -393,9 +393,9 @@ n *= 2; // now n = 14 (same as n = n * 2)
393393
alert( n ); // 14
394394
```
395395
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.
397397
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:
399399
400400
```js run
401401
let n = 2;
@@ -405,13 +405,13 @@ n *= 3 + 5;
405405
alert( n ); // 16 (right part evaluated first, same as n *= 8)
406406
```
407407
408-
## Comma
408+
## Virgula
409409
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.
411411
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ă.
413413
414-
For example:
414+
De exemplu:
415415
416416
```js run
417417
*!*
@@ -421,19 +421,19 @@ let a = (1 + 2, 3 + 4);
421421
alert( a ); // 7 (the result of 3 + 4)
422422
```
423423
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.
425425
426426
```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.
428428
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.
430430
```
431431
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?
433433
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.
435435
436-
For example:
436+
De exemplu:
437437
438438
```js
439439
// three operations in one line
@@ -442,4 +442,4 @@ for (*!*a = 1, b = 3, c = a * b*/!*; a < 10; a++) {
442442
}
443443
```
444444
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

Comments
 (0)