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/05-data-types/08-keys-values-entries/article.md
+41-41Lines changed: 41 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ Veri yapılarından biraz uzaklaşıp bunların döngülerinden bahsedecek olurs
5
5
6
6
Bir önceki bölümde `map.keys()`, `map.values()`, `map.entries()` gibi metodlar vardı.
7
7
8
-
Bu metodlar `generi`c metorlardır. Bunların veri yapılarında kullanılması çoğu dilde ortaktır. Eğer yenei bir veri yapısı yapmak istiyorsanız siz de bunların uygulamasını yapmalısınız.
8
+
Bu metodlar `generic` metorlardır. Bunların veri yapılarında kullanılması çoğu dilde ortaktır. Eğer yeni bir veri yapısı yapmak istiyorsanız siz de bunların uygulamasını yapmalısınız.
9
9
10
10
Bunlar:
11
11
-`Map`
@@ -71,87 +71,87 @@ for(let deger of Object.values(kullanici)) {
71
71
Bu baya işe yarar bir özelliktir. Fakat symbol özelliklerini almak istiyorsanız [Object.getOwnPropertySymbols](mdn:js/Object/getOwnPropertySymbols) metodunu kullanabilirsiniz. Ayrıca [Reflect.ownKeys(obj)](mdn:js/Reflect/ownKeys) *tüm* anahtarları döner.
72
72
```
73
73
74
-
## Object.fromEntries to transform objects
74
+
## Nesneleri dönüştürmek için Object.fromEntries
75
75
76
-
Sometimes we need to perform a transformation of an object to `Map` and back.
76
+
Bazen bir nesneyi `Map`e dönüştürüp ardından onu objeye geri dönüştürmemiz gerekir
77
77
78
-
We already have `new Map(Object.entries(obj))`to make a `Map` from `obj`.
78
+
Halihazırda `obj`den `Map` yapmak için `new Map(Object.entries(obj))`var.
79
79
80
-
The syntax of `Object.fromEntries`does the reverse. Given an array of `[key, value]`pairs, it creates an object:
80
+
`Object.fromEntries`in sözdizimi(syntaxi) tam tersini yapar. `[key, value]`çifti dizisi verildiğinde, bir obje oluşturur:
81
81
82
82
```js run
83
-
letprices=Object.fromEntries([
84
-
['banana', 1],
85
-
['orange', 2],
86
-
['meat', 4]
83
+
letfiyatlar=Object.fromEntries([
84
+
['muz', 1],
85
+
['portakal', 2],
86
+
['et', 4]
87
87
]);
88
88
89
-
//now prices = { banana: 1, orange: 2, meat: 4 }
89
+
//şimdi fiyatlar = { muz: 1, portakal: 2, et: 4 }
90
90
91
-
alert(prices.orange); // 2
91
+
alert(fiyatlar.portakal); // 2
92
92
```
93
93
94
-
Let's see practical applications.
94
+
Pratik uygulamaları görelim.
95
95
96
-
For example, we'd like to create a new object with double prices from the existing one.
96
+
Örneğin, mevcut olandan iki kat fiyatla yeni bir nesne oluşturmak istiyoruz.
97
97
98
-
For arrays, we have `.map` method that allows to transform an array, but nothing like that for objects.
98
+
Diziler için, bir diziyi dönüştürmeye izin veren .map metodumuz var, ancak nesneler için böyle bir şey yok.
...Or we can represent the object as an `Array`using `Object.entries`, then perform the operations with `map` (and potentially other array methods), and then go back using`Object.fromEntries`.
117
+
...Veya `Object.entries` kullanarak nesneyi bir `Array`olarak temsil edebilir, daha sonra işlemleri `map` (ve muhtemelen diğer dizi metodları) ile gerçekleştirebilir ve daha sonra`Object.fromEntries` kullanarak geri dönebiliriz.
118
118
119
-
Let's do it for our object:
119
+
Bunu bizim objemiz için yapalım:
120
120
121
121
```js run
122
-
letprices= {
123
-
banana:1,
124
-
orange:2,
125
-
meat:4,
122
+
letfiyatlar= {
123
+
muz:1,
124
+
portakal:2,
125
+
et:4,
126
126
};
127
127
128
128
*!*
129
-
letdoublePrices=Object.fromEntries(
129
+
letikiKatiFiyatlar=Object.fromEntries(
130
130
// convert to array, map, and then fromEntries gives back the object
131
-
Object.entries(prices).map(([key, value]) => [key, value *2])
131
+
Object.entries(fiyatlar).map(([key, value]) => [key, value *2])
132
132
);
133
133
*/!*
134
134
135
-
alert(doublePrices.meat); // 8
135
+
alert(ikiKatiFiyatlar.et); // 8
136
136
```
137
137
138
-
It may look difficult from the first sight, but becomes easy to understand after you use it once or twice.
138
+
İlk görüşte zor görünebilir, ancak bir veya iki kez kullandıktan sonra anlaşılması kolaylaşır.
139
139
140
-
We also can use `fromEntries`to get an object from `Map`.
140
+
`Map`ten bir obje almak için`fromEntries`de kullanabiliriz.
141
141
142
-
E.g. we have a `Map` of prices, but we need to pass it to a 3rd-party code that expects an object.
142
+
Örneğin. Bir fiyat `Map`imiz var, ancak bunu bir nesne bekleyen 3. taraf koduna geçirmemiz gerekiyor.
0 commit comments