Skip to content

Commit a03304d

Browse files
committed
translated until line 50
1 parent bac68e8 commit a03304d

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11

22
# Map and Set
33

4-
Till now, we've learned about the following complex data structures:
4+
Până acum, am învățat despre următoarele structuri complexe de date:
55

6-
- Objects are used for storing keyed collections.
7-
- Arrays are used for storing ordered collections.
6+
- Obiectele sunt utilizate pentru stocarea colecțiilor cu chei.
7+
- Array-urile sunt utilizate pentru stocarea colecțiilor ordonate.
88

9-
But that's not enough for real life. That's why `Map` and `Set` also exist.
9+
Dar acest lucru nu este suficient pentru viața reală. De aceea există și `Map` și `Set`.
1010

1111
## Map
1212

13-
[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) is a collection of keyed data items, just like an `Object`. But the main difference is that `Map` allows keys of any type.
13+
[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) este o colecție de elemente de date cu chei, exact ca un `Object`. Dar diferența principală este că `Map` permite chei de orice tip.
1414

15-
Methods and properties are:
15+
Metodele și proprietățile sunt:
1616

17-
- [`new Map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/Map) -- creates the map.
18-
- [`map.set(key, value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set) -- stores the value by the key.
19-
- [`map.get(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) -- returns the value by the key, `undefined` if `key` doesn't exist in map.
20-
- [`map.has(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) -- returns `true` if the `key` exists, `false` otherwise.
21-
- [`map.delete(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete) -- removes the element (the key/value pair) by the key.
22-
- [`map.clear()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear) -- removes everything from the map.
23-
- [`map.size`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size) -- returns the current element count.
17+
- [`new Map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/Map) -- creează map.
18+
- [`map.set(key, value)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/set) -- stochează valoarea în funcție de cheie.
19+
- [`map.get(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) -- returnează valoarea în funcție de cheie, `undefined` dacă `key` nu există în map.
20+
- [`map.has(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) -- returnează `true` dacă `key` există, `false` în caz contrar.
21+
- [`map.delete(key)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/delete) -- elimină elementul (perechea cheie/valoare) în funcție de cheie.
22+
- [`map.clear()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/clear) -- elimină totul din map.
23+
- [`map.size`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/size) -- returnează numărul curent de elemente.
2424

25-
For instance:
25+
De exemplu:
2626

2727
```js run
2828
let map = new Map();
2929

30-
map.set('1', 'str1'); // a string key
31-
map.set(1, 'num1'); // a numeric key
32-
map.set(true, 'bool1'); // a boolean key
30+
map.set('1', 'str1'); // o cheie string
31+
map.set(1, 'num1'); // o cheie numerică
32+
map.set(true, 'bool1'); // o cheie boolean
3333

34-
// remember the regular Object? it would convert keys to string
35-
// Map keeps the type, so these two are different:
34+
// vă amintiți de obiectul obișnuit Object? acesta ar converti cheile în șiruri de caractere
35+
// Map păstrează tipul, deci acestea două sunt diferite:
3636
alert( map.get(1) ); // 'num1'
3737
alert( map.get('1') ); // 'str1'
3838

3939
alert( map.size ); // 3
4040
```
4141

42-
As we can see, unlike objects, keys are not converted to strings. Any type of key is possible.
42+
După cum putem vedea, spre deosebire de obiecte, cheile nu sunt convertite în șiruri de caractere. Orice tip de cheie este posibilă.
4343

44-
```smart header="`map[key]` isn't the right way to use a `Map`"
45-
Although `map[key]` also works, e.g. we can set `map[key] = 2`, this is treating `map` as a plain JavaScript object, so it implies all corresponding limitations (only string/symbol keys and so on).
44+
```smart header="`map[key]` nu este modalitatea corectă de utilizare a unui `Map`"
45+
Deși `map[key]` funcționează de asemenea, e.g. putem seta `map[key] = 2`, acest lucru tratează `map` ca pe un simplu obiect JavaScript, deci implică toate limitările corespunzătoare (numai chei de tip string/simbol și așa mai departe).
4646

47-
So we should use `map` methods: `set`, `get` and so on.
47+
Deci ar trebui să folosim metodele `map`: `set`, `get` și așa mai departe.
4848
```
4949
50-
**Map can also use objects as keys.**
50+
**Map poate folosi și obiecte ca și chei.**
5151
5252
For instance:
5353

0 commit comments

Comments
 (0)