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
+57-56Lines changed: 57 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -262,16 +262,16 @@ Artırma/Azaltma sadece değişkenlere uygulanabilirler. `5++` gibi bir kullanı
262
262
`++` ve `--` operatörleri değişkenden önce veya sonra kullanılabilirler.
263
263
264
264
265
-
-When the operator goes after the variable, it is called a "postfix form":`counter++`.
266
-
-The "prefix form"is when the operator stands before the variable:`++counter`.
265
+
-Operatör değişkenden sonra geliyorsa ona "postfix form" deriz:`counter++`.
266
+
-"prefix form"ise opeatörün değişkenden önce geldiği durumdur:`++counter`.
267
267
268
-
Both of these records do the same: increase `counter`by`1`.
268
+
Bu iki durumda da aynı işlem yapılır:`counter`değişkeni`1` arttırılır.
269
269
270
-
Is there any difference? Yes, but we can only see it if we use the returned value of`++/--`.
270
+
Peki bir farkları var mı? Evet, fakat bunu `++/--` işleminden dönen değerleri kullanırsak görebiliriz.
271
271
272
-
Let's clarify. As we know, all operators return a value. Increment/decrement is not an exception here. The prefix form returns the new value, while the postfix form returns the old value (prior to increment/decrement).
272
+
Şöyle açıklayabiliriz. Bildiğimiz üzere tüm operatörler bir değer döndürür. arttırma/azaltma opeatörleri buna bir istisna değildir. Prefix formu oluşan yeni değeri döndürürken, postfix formu eski değeri(arttırma/azaltma işlemi yapılmadan önceki) döndürür.
273
273
274
-
To see the difference, here's the example:
274
+
Farkı görebilmemiz için örneği inceleyelim:
275
275
276
276
```js run
277
277
let counter = 1;
@@ -280,9 +280,9 @@ let a = ++counter; // (*)
280
280
alert(a); // *!*2*/!*
281
281
```
282
282
283
-
Here in the line `(*)`the prefix call`++counter`increments `counter`and returns the newvalue that is `2`. So the `alert`shows`2`.
283
+
`(*)`satırında *prefix* formundaki`++counter``counter`değişkenini arttırır ve yeni değer olan `2` yi döndürür. Yani`alert`bize`2` değerini gösterecektir.
284
284
285
-
Now let's use the postfix form:
285
+
Şimdi de postfix kullanıma bakalım:
286
286
287
287
```js run
288
288
let counter = 1;
@@ -291,53 +291,53 @@ let a = counter++; // (*) changed ++counter to counter++
291
291
alert(a); // *!*1*/!*
292
292
```
293
293
294
-
In the line `(*)` the *postfix* form `counter++` also increments `counter`, but returns the *old* value (prior to increment). So the `alert` shows `1`.
294
+
`(*)`satırında*postfix*formundaki `++counter` de aynı şekilde `counter` değişkenini arttırır fakat bu sefer değişkenin *eski* değerini(arttırma işlemi yapılmadan önceki) değerini döndürür. Yani`alert`bize`1` değerini gösterecektir.
295
295
296
-
To summarize:
296
+
Özetle:
297
297
298
-
- If the result of increment/decrement is not used, then there is no difference in which form to use:
298
+
-Eğer arttırma/azaltma işleminin sonucunu kullanmıyorsak hangi formu kullandığımızın bir farkı olmaz:
299
299
300
300
```js run
301
301
let counter = 0;
302
302
counter++;
303
303
++counter;
304
-
alert( counter ); // 2, the lines above did the same
304
+
alert( counter ); // 2, iki satır da aynı işlemi yaptı.
305
305
```
306
-
- If we'd like to increase the value *and* use the result of the operator right now, then we need the prefix form:
306
+
-Eğer bir değeri arttıracak *ve* onu aynı anda(o işlem sırasında) kullanacaksak, prefix formunu kullanmamız gerekir:
307
307
308
308
```js run
309
309
let counter = 0;
310
310
alert( ++counter ); // 1
311
311
```
312
-
-If we'd like to increment, but use the previous value, then we need the postfix form:
312
+
-Eğer arttırma yapacak fakat arttırma yapmadan yapmadan önceki değeri kullanacaksak, postfix formunu kullanmamız gerekir:
313
313
314
314
```js run
315
315
let counter = 0;
316
316
alert( counter++ ); // 0
317
317
```
318
318
319
-
````smart header="Increment/decrement among other operators"
320
-
Operators `++/--` can be used inside an expression as well. Their precedence is higher than most other arithmetical operations.
319
+
````smart header="Diğer operatörler arasında arttırma/azaltma"
320
+
`++/--`operatörleri ayrıca bir ifadenin içinde kullanılabilirler. Öncelikleri diğer tüm operatörlerden daha yüksektir.
321
321
322
-
For instance:
322
+
Örneğin:
323
323
324
324
```js run
325
325
let counter = 1;
326
326
alert( 2 * ++counter ); // 4
327
327
```
328
328
329
-
Compare with:
329
+
alttaki örnek ile karşılaştıralım:
330
330
331
331
```js run
332
332
let counter = 1;
333
-
alert( 2 * counter++ ); // 2, because counter++ returns the "old" value
333
+
alert( 2 * counter++ ); // 2, çünkü counter++ "eski" değeri döndürecektir
334
334
```
335
335
336
-
Though technically allowable, such notation usually makes the code less readable. One line does multiple things -- not good.
336
+
Teknik olarak doğru olmakla birlikte bu tür kullanımlar kodu daha az okunur kılar. Bir satırında birden çok işlem yapılması çok iyi değildir.
337
337
338
-
While reading the code, a fast "vertical" eye-scan can easily miss such `counter++`, and it won't be obvious that the variable increases.
338
+
Kod okurken hızlı bir göz taraması sırasında `counter++` ifadesini gözden kaçırmamız oldukça olasıdır. Değişkenin arttırıldığı açıkça gözükmeyebilir.
339
339
340
-
The "one line -- one action" style is advised:
340
+
"Bir satır -- bir işlem" stili önerilir:
341
341
342
342
```js run
343
343
let counter = 1;
@@ -346,29 +346,29 @@ counter++;
346
346
```
347
347
````
348
348
349
-
## Bitwise operators
349
+
## Bitsel(Bitwise) Operatörler
350
350
351
-
Bitwise operators treat arguments as 32-bit integer numbers and work on the level of their binary representation.
351
+
Bitsel operatörler argümanlara 32-bitlik doğal sayı gibi davranır ve ikili gösterimleri düzeyinde çalışır.
352
352
353
-
These operators are not JavaScript-specific. They are supported in most programming languages.
353
+
Bu operatörler JavaScript'e özgü değildir. Çoğu programlama dilinde bulunurlar.
354
354
355
-
The list of operators:
355
+
Operatörlerin listesi:
356
356
357
-
-AND ( `&` )
358
-
-OR ( `|` )
359
-
-XOR ( `^` )
360
-
-NOT ( `~` )
361
-
-LEFTSHIFT ( `<<` )
362
-
-RIGHTSHIFT ( `>>` )
363
-
-ZERO-FILLRIGHTSHIFT ( `>>>` )
357
+
- AND -- VE ( `&` )
358
+
- OR -- VEYA ( `|` )
359
+
- XOR -- ÖZEL VEYA ( `^` )
360
+
- NOT -- DEĞİL ( `~` )
361
+
- LEFT SHIFT -- SOLA KAYDIRMA ( `<<` )
362
+
- RIGHT SHIFT -- SAĞ KAYDIRMA ( `>>` )
363
+
- ZERO-FILL RIGHT SHIFT -- SIFIR DOLDURARAK SAĞ KAYDIRMA ( `>>>` )
364
364
365
-
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.
365
+
Bu oparatörlerin çok nadir kullanılır. Onları anlamak için düşük seviyeli sayı temsiline girmemiz gerekiyor ve özellikle de yakın zamanda onlara ihtiyaç duymayacağımızdan şu anda bunu yapmak uygun olmayacaktır. Merak ediyorsanız, MDN ile ilgili [Bitwise Operators](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators) makalesini okuyabilirsiniz. Gerçek bir ihtiyacınız olduğunda bunu yapmak daha pratik olacaktır.
366
366
367
-
## Modify-in-place
367
+
## Modify-in-place (Yerinde Değiştir)
368
368
369
-
We often need to apply an operator to a variable and store the newresultin that same variable.
369
+
Bazen bir değişken üzerinde bir operatör işlemi yaparız ve yeni oluşacak değerini aynı değişkende tutmak isteriz.
370
370
371
-
For example:
371
+
Örneğin:
372
372
373
373
```js
374
374
let n = 2;
@@ -377,62 +377,63 @@ n = n * 2;
377
377
```
378
378
379
379
This notation can be shortened using the operators `+=` and `*=`:
380
+
Bu işlemler `+=` ve `*=` kullanılarak kısaltılabilir:
380
381
381
382
```js run
382
383
let n = 2;
383
-
n += 5; // now n = 7 (same as n = n + 5)
384
-
n *= 2; // now n = 14 (same as n = n * 2)
384
+
n += 5; // şu an n = 7 (n = n + 5 ile aynı)
385
+
n *= 2; // şu an n = 14 (n = n * 2 ile aynı)
385
386
386
387
alert( n ); // 14
387
388
```
388
389
389
-
Short "modify-and-assign"operators exist for all arithmetical and bitwise operators:`/=`, `-=`, etc.
390
+
Kısa olan "modify-and-assign" operatörleri tüm aritmetik ve bitsel operatörler için mevcuttur: `/=`, `-=`, vb.
390
391
391
-
Such operators have the same precedence as a normal assignment, so they run after most other calculations:
392
+
Bu tür operatörler normal bir atama(assignment) ile aynı önceliğe sahiptir, bu yüzden diğer birçok hesaplamalardan sonra çalışırlar.
392
393
393
394
```js run
394
395
let n = 2;
395
396
396
397
n *= 3 + 5;
397
398
398
-
alert( n ); // 16 (right part evaluated first, same as n *= 8)
399
+
alert( n ); // 16 (önce sağ kısımda işleem yapıldı, n *= 8 gibi)
399
400
```
400
401
401
-
## Comma
402
+
## Virgül
402
403
403
-
The comma operator `,`is one of the rarest and most unusual operators. Sometimes, it's used to write shorter code, so we need to know it in order to understand what's going on.
404
+
Virgül operatörü `,` nadir ve en alışılmadık operatörlerden birisidir. Bazen daha kısa kodlar yazmak için kullanılır. Bu yüzden neler olduğunu anlamak için bu operatörü de bilmemiz gerekiyor.
404
405
405
-
The comma operator allows us to evaluate several expressions, dividing them with a comma `,`. Eachof them is evaluated but only the result of the last one is returned.
406
+
Virgül operatörü birden fazla ifadeyi virgül `,` ile ayırarak hesaplamamıza olanak sağlar. Her bir ifade işleme alınır fakat bu ifadelerden sadece sonuncusu döndürülür.
406
407
407
-
For example:
408
+
Örneğin:
408
409
409
410
```js run
410
411
*!*
411
412
let a = (1 + 2, 3 + 4);
412
413
*/!*
413
414
414
-
alert( a ); // 7 (the result of 3 + 4)
415
+
alert( a ); // 7 (3 + 4 işleminin sonucu)
415
416
```
416
417
417
-
Here, the first expression`1 + 2`is evaluated and its result is thrown away. Then, `3 + 4`is evaluated and returned as the result.
418
+
Burada, ilk ifade olan `1 + 2` işleme giriyor fakat sonucu çöpe atılıyor. Sonrasında gelen `3 + 4` işleme giriyor ve sonuç olarak geri döndürülüyor.
418
419
419
-
```smart header="Comma has a very low precedence"
420
-
Please note that the comma operator has very low precedence, lower than `=`, so parentheses are important in the example above.
420
+
```smart header="Virgül operatörünün önceliği çok düşüktür"
421
+
Unutmamak gerekir ki virgül oparatörü çok düşük bir önceliğe sahiptir, önceliği `=` den bile daha düşüktür; bu yüzden yukardaki örnekte gördüğümüz gibi parantezler çok önemlidir.
421
422
422
-
Without them: `a =1+2, 3+4`evaluates `+`first, summing the numbers into `a =3, 7`, then the assignment operator`=`assigns `a =3`, and finally the number after the comma,`7`, is not processed so it's ignored.
423
+
Parantezler olmadan: `a = 1 + 2, 3 + 4` ifadesinde önce `+` işleme alınır, değerler toplanarak `a = 3, 7` ifadesine çevirilir, ondan sonra atama operatörü `=` ile `a = 3` ataması yapılır, ve sonuç olarak virgülden sonraki sayı olan `7` işlenmeyerek yok sayılır.
423
424
```
424
425
425
-
Why do we need an operator that throws away everything except the last part?
426
+
Peki neden son kısım hariç her şeyi yok sayan bir operatöre neden ihtiyacımız var?
426
427
427
-
Sometimes, people use it in more complex constructs to put several actions in one line.
428
+
Bazen bizler, bir satırda birkaç işlem yapılan karmaşık yapılarda bu operatörü kullanırız.
428
429
429
-
For example:
430
+
Örneğin:
430
431
431
432
```js
432
-
// three operations in one line
433
+
// Bir satırda 3 farklı işlem
433
434
for (*!*a = 1, b = 3, c = a * b*/!*; a < 10; a++) {
434
435
...
435
436
}
436
437
```
437
438
438
-
Such tricks are used in many JavaScript frameworks. That's why we're mentioning them. But, usually, they don't improve code readability so we should think well before using them.
439
+
Bu tarz numaralar bir çok JavaScript frameworklerinde kullanılır. Bu yüzden bunladan bahsettik. Ama genelde bunlar kodun okunabilirliğini azaltıyorlar. Bu yüzden kullanmadan önce iyi düşünmek gerekir.
0 commit comments