@@ -991,11 +991,11 @@ console.log(`Calisanin ismi: ${calisan.getIsim()}`); // Calisanin ismi: John Doe
991
991
992
992
993
993
## ** Sınıflar**
994
- ### Prefer ES2015/ES6 classes over ES5 plain functions
995
- It's very difficult to get readable class inheritance , construction, and method
996
- definitions for classical ES5 classes. If you need inheritance (and be aware
997
- that you might not), then prefer ES2015/ES6 classes. However, prefer small functions over
998
- classes until you find yourself needing larger and more complex objects .
994
+ ### Yalın ES5 fonksiyonları yerine ES2015/ES6 sınıflarını tercih edin
995
+ Klasik ES5 sınıfları için okunabilir sınıf kalıtımları , construction ve metod tanımlarını
996
+ almak çok zordur. Eğer kalıtıma ihtiyacınız varsa (ihtiyacınızın olmayabileceğinin farkında olun),
997
+ o zaman ES2015/ES6 sınıflarını tercih edin. Ancak, daha büyük ve karmaşık nesnelerle uğraşana
998
+ kadar sınıflar yerine küçük fonksiyonları kullanın .
999
999
1000
1000
** Kötü:**
1001
1001
``` javascript
@@ -1067,81 +1067,81 @@ class Human extends Mammal {
1067
1067
** [ ⬆ en başa dön] ( #içindekiler ) **
1068
1068
1069
1069
1070
- ### Use method chaining
1071
- This pattern is very useful in JavaScript and you see it in many libraries such
1072
- as jQuery and Lodash. It allows your code to be expressive, and less verbose .
1073
- For that reason, I say, use method chaining and take a look at how clean your code
1074
- will be. In your class functions, simply return ` this ` at the end of every function ,
1075
- and you can chain further class methods onto it .
1070
+ ### Metod zincirleme yöntemini kullanın
1071
+ Bu yöntem JavaScript'te çok kullanışlıdır ve bunu jQuery ve Lodash gibi birçok kütüphanede görebilirsiniz.
1072
+ Kodunuzun daha anlamlı ve daha az detaylı olmasını sağlar .
1073
+ Bu nedenle, metod zincirleme yöntemini bir kez kullanın ve kodunuzun ne kadar temiz olacağına bir göz atın derim.
1074
+ Sınıf fonksiyonlarında basitçe her fonksiyon sonunda ` this ` döndürün ,
1075
+ böylece daha fazla sınıf metodu zincirleyebilirsiniz .
1076
1076
1077
1077
** Kötü:**
1078
1078
``` javascript
1079
- class Car {
1080
- constructor (make , model , color ) {
1081
- this .make = make ;
1079
+ class Araba {
1080
+ constructor (marka , model , renk ) {
1081
+ this .marka = marka ;
1082
1082
this .model = model;
1083
- this .color = color ;
1083
+ this .renk = renk ;
1084
1084
}
1085
1085
1086
- setMake ( make ) {
1087
- this .make = make ;
1086
+ setMarka ( marka ) {
1087
+ this .marka = marka ;
1088
1088
}
1089
1089
1090
1090
setModel (model ) {
1091
1091
this .model = model;
1092
1092
}
1093
1093
1094
- setColor ( color ) {
1095
- this .color = color ;
1094
+ setRenk ( renk ) {
1095
+ this .renk = renk ;
1096
1096
}
1097
1097
1098
- save () {
1099
- console .log (this .make , this .model , this .color );
1098
+ kaydet () {
1099
+ console .log (this .marka , this .model , this .renk );
1100
1100
}
1101
1101
}
1102
1102
1103
- const car = new Car (' Ford' ,' F-150' ,' red ' );
1104
- car . setColor ( ' pink ' );
1105
- car . save ();
1103
+ const araba = new Araba (' Ford' ,' F-150' ,' kirmizi ' );
1104
+ araba . setRenk ( ' pembe ' );
1105
+ araba . kaydet ();
1106
1106
```
1107
1107
1108
1108
** İyi:**
1109
1109
``` javascript
1110
- class Car {
1111
- constructor (make , model , color ) {
1112
- this .make = make ;
1110
+ class Araba {
1111
+ constructor (marka , model , renk ) {
1112
+ this .marka = marka ;
1113
1113
this .model = model;
1114
- this .color = color ;
1114
+ this .renk = renk ;
1115
1115
}
1116
1116
1117
- setMake ( make ) {
1118
- this .make = make ;
1119
- // NOTE: Returning this for chaining
1117
+ setMarka ( marka ) {
1118
+ this .marka = marka ;
1119
+ // NOT: Zincirleme için ' this' döndürülüyor
1120
1120
return this ;
1121
1121
}
1122
1122
1123
1123
setModel (model ) {
1124
1124
this .model = model;
1125
- // NOTE: Returning this for chaining
1125
+ // NOT: Zincirleme için ' this' döndürülüyor
1126
1126
return this ;
1127
1127
}
1128
1128
1129
- setColor ( color ) {
1130
- this .color = color ;
1131
- // NOTE: Returning this for chaining
1129
+ setRenk ( renk ) {
1130
+ this .renk = renk ;
1131
+ // NOT: Zincirleme için ' this' döndürülüyor
1132
1132
return this ;
1133
1133
}
1134
1134
1135
- save () {
1136
- console .log (this .make , this .model , this .color );
1137
- // NOTE: Returning this for chaining
1135
+ kaydet () {
1136
+ console .log (this .marka , this .model , this .renk );
1137
+ // NOT: Zincirleme için ' this' döndürülüyor
1138
1138
return this ;
1139
1139
}
1140
1140
}
1141
1141
1142
- const car = new Car (' Ford' ,' F-150' ,' red ' )
1143
- .setColor ( ' pink ' )
1144
- .save ();
1142
+ const araba = new Araba (' Ford' ,' F-150' ,' kirmizi ' )
1143
+ .setRenk ( ' pembe ' )
1144
+ .kaydet ();
1145
1145
```
1146
1146
** [ ⬆ en başa dön] ( #içindekiler ) **
1147
1147
0 commit comments