Skip to content

Commit 3dec4b9

Browse files
authored
Merge pull request #9 from ook0/master
Don't write to global functions çevirildi
2 parents 3df0e12 + ca43c4e commit 3dec4b9

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -597,16 +597,8 @@ const addItemToCart = (cart, item) => {
597597

598598
**[⬆ en başa dön](#içindekiler)**
599599

600-
### Don't write to global functions
601-
Polluting globals is a bad practice in JavaScript because you could clash with another
602-
library and the user of your API would be none-the-wiser until they get an
603-
exception in production. Let's think about an example: what if you wanted to
604-
extend JavaScript's native Array method to have a `diff` method that could
605-
show the difference between two arrays? You could write your new function
606-
to the `Array.prototype`, but it could clash with another library that tried
607-
to do the same thing. What if that other library was just using `diff` to find
608-
the difference between the first and last elements of an array? This is why it
609-
would be much better to just use ES2015/ES6 classes and simply extend the `Array` global.
600+
### Global fonksiyonlar yazma.
601+
Javascript'te globalleri kirletmek kötü bir uygulamadır çünkü diğer bir kütüphaneyle çakışabilirsiniz ve API kullanıcınız uygulamayı canlı ortama sunduğunda alacağı bir hataya kadar bu durumdan haberdar olmayabilir. Bir örnek üzerinden düşünelim: eğer JavaScript'in sahip olduğu Array metodunu, iki dizi arasındaki farkı gösteren bir `diff` metoduna sahip olacak şekilde genişletmek isteseydik? `Array.prototype` a yeni bir fonksiyon yazabilirsin, ama bu, aynı şeyi yapmaya çalışan başka bir kütüphane ile çakışabilir. Ya başka bir kütüphane `diff` metodunu, bir dizinin ilk elemanı ile son elemanı arasındaki farkı bulmak için kullanıyor olsaydı? Bu yüzden ES2015/ES6 sınıflarını kullanmak ve basitçe `Array` i kalıtımla almak çok daha iyi olacaktır.
610602

611603
**Kötü:**
612604
```javascript

0 commit comments

Comments
 (0)