Skip to content

Commit efd5c5a

Browse files
committed
translated until line 103
1 parent a03304d commit efd5c5a

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

1-js/05-data-types/07-map-set/article.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,49 +49,49 @@ Deci ar trebui să folosim metodele `map`: `set`, `get` și așa mai departe.
4949
5050
**Map poate folosi și obiecte ca și chei.**
5151
52-
For instance:
52+
De exemplu:
5353
5454
```js run
5555
let john = { name: "John" };
5656
57-
// for every user, let's store their visits count
57+
// pentru fiecare utilizator, să stocăm numărul de vizite ale acestuia
5858
let visitsCountMap = new Map();
5959
60-
// john is the key for the map
60+
// john este cheia pentru hartă
6161
visitsCountMap.set(john, 123);
6262
6363
alert( visitsCountMap.get(john) ); // 123
6464
```
6565

66-
Using objects as keys is one of the most notable and important `Map` features. The same does not count for `Object`. String as a key in `Object` is fine, but we can't use another `Object` as a key in `Object`.
66+
Utilizarea obiectelor drept chei este una dintre cele mai notabile și importante caracteristici ale `Map`. Același lucru nu se pune la socoteală pentru `Object`. String ca cheie în `Object` este în regulă, dar nu putem folosi un alt `Object` drept cheie în `Object`.
6767

68-
Let's try:
68+
Să încercăm:
6969

7070
```js run
7171
let john = { name: "John" };
7272
let ben = { name: "Ben" };
7373

74-
let visitsCountObj = {}; // try to use an object
74+
let visitsCountObj = {}; // încercați să folosiți un obiect
7575

76-
visitsCountObj[ben] = 234; // try to use ben object as the key
77-
visitsCountObj[john] = 123; // try to use john object as the key, ben object will get replaced
76+
visitsCountObj[ben] = 234; // încercați să folosiți obiectul ben ca și cheie
77+
visitsCountObj[john] = 123; // încercați să utilizați obiectul john ca cheie, obiectul ben va fi înlocuit.
7878

7979
*!*
80-
// That's what got written!
80+
// Asta este ceea ce s-a scris!
8181
alert( visitsCountObj["[object Object]"] ); // 123
8282
*/!*
8383
```
8484

85-
As `visitsCountObj` is an object, it converts all `Object` keys, such as `john` and `ben` above, to same string `"[object Object]"`. Definitely not what we want.
85+
Deoarece `visitsCountObj` este un obiect, acesta convertește toate cheile `Object`, cum ar fi `john` și `ben` de mai sus, în același șir de caractere `"[object Object]"`. Cu siguranță nu este ceea ce ne dorim.
8686

87-
```smart header="How `Map` compares keys"
88-
To test keys for equivalence, `Map` uses the algorithm [SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero). It is roughly the same as strict equality `===`, but the difference is that `NaN` is considered equal to `NaN`. So `NaN` can be used as the key as well.
87+
```smart header="Cum compară `Map` cheile"
88+
Pentru a testa echivalența cheilor, `Map` folosește algoritmul [SameValueZero](https://tc39.github.io/ecma262/#sec-samevaluezero). Este aproximativ la fel ca egalitatea strictă `===`, dar diferența este că `NaN` este considerat egal cu `NaN`. Astfel `NaN` poate fi folosit și ca cheie de asemenea.
8989

90-
This algorithm can't be changed or customized.
90+
Acest algoritm nu poate fi modificat sau personalizat.
9191
```
9292
93-
````smart header="Chaining"
94-
Every `map.set` call returns the map itself, so we can "chain" the calls:
93+
````smart header="Înlănțuire"
94+
Fiecare apel `map.set` returnează map însăși, astfel încât putem "înlănțui" apelurile:
9595
9696
```js
9797
map.set('1', 'str1')
@@ -100,7 +100,7 @@ map.set('1', 'str1')
100100
```
101101
````
102102
103-
## Iteration over Map
103+
## Iterare peste Map
104104
105105
For looping over a `map`, there are 3 methods:
106106

0 commit comments

Comments
 (0)