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/09-classes/01-class/article.md
+25-24Lines changed: 25 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
1
1
2
-
# Class basic syntax
2
+
# Temel Sınıf sözdizimi
3
3
4
4
```quote author="Wikipedia"
5
-
In object-oriented programming, a *class* is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods).
5
+
Sınıf, nesne yönelimli programlama dillerinde nesnelerin özelliklerini, davranışlarını ve başlangıç durumlarını tanımlamak için kullanılan şablonlara verilen addır.
6
6
```
7
7
8
-
In practice, we often need to create many objects of the same kind, like users, or goods or whatever.
8
+
Pratikte, aynı türden birçok nesne oluşturmamız gerekebilir, kullanıcılar veya malzemeler gibi.
9
9
10
-
As we already know from the chapter <info:constructor-new>, `new function` can help with that.
10
+
<info:constructor-new>, kısmından bildiğimiz gibi `new(yeni) fonksiyonu` bize bu konuda yardımcı olabilir.
11
11
12
-
But in the modern JavaScript, there's a more advanced "class" construct, that introduces great new features which are useful for object-oriented programming.
12
+
Ancak modern Javascript'de bundan daha gelişmiş bir "sınıf" yapısı var. Bu yapı nesne tabanlı programlamaya yeni ve faydalı özellikler getiriyor.
13
13
14
-
## The "class" syntax
14
+
## Sınıf sözdizimi
15
15
16
-
The basic syntax is:
16
+
Temel sözdizimi:
17
17
```js
18
18
classMyClass {
19
19
// class methods
@@ -25,11 +25,11 @@ class MyClass {
25
25
}
26
26
```
27
27
28
-
Then`new MyClass()`creates a new object with all the listed methods.
28
+
Sonra`new MyClass()`bu metotlarla birlikte yeni bir nesne oluşturuyor.
29
29
30
-
The `constructor()`method is called automatically by `new`, so we can initialize the object there.
30
+
`constructor()`metodu `new` tarafından otomatik olarak çağırılıyor. Bu sayede nesneyi orada tanımlayabiliyoruz.
31
31
32
-
For example:
32
+
Örnek olarak:
33
33
34
34
```js run
35
35
classUser {
@@ -49,28 +49,29 @@ let user = new User("John");
49
49
user.sayHi();
50
50
```
51
51
52
-
When `new User("John")`is called:
53
-
1.A new object is created.
54
-
2.The `constructor`runs with the given argument and assigns `this.name` to it.
52
+
`new User("John")`çağırıldığında:
53
+
1.Yeni bir nesne oluşturuluyor.
54
+
2.`constructor`verilen argümanla çalışıyor ve buna `this.name`'i atıyor.
55
55
56
-
...Then we can call methods, such as `user.sayHi`.
57
56
57
+
...Daha sonra `user.sayHi` gibi metodları çağırabiliriz.
58
58
59
-
```warn header="No comma between class methods"
60
-
A common pitfall for novice developers is to put a comma between class methods, which would result in a syntax error.
61
59
62
-
The notation here is not to be confused with object literals. Within the class, no commas are required.
60
+
```warn header="Sınıf metodları arasında virgül kullanılmaz"
61
+
Acemi geliştiricilerin düştüğü bir hata da, sınıf metodları arasına virgül koymak. Bu da sözdimizi hatasına neden oluyor.
62
+
63
+
Buradaki notasyon nesne sabitleriyle karıştırılmamalı. Sınıf içinde virgüle ihtiyaç yok.
63
64
```
64
65
65
-
## What is a class?
66
+
## Sınıf nedir?
66
67
67
-
So, what exactly is a `class`? That's not an entirely new language-level entity, as one might think.
68
+
Peki, `class` (sınıf) tam olarak nedir? Bu aslında tam olarak yeni bir dil seviyesi obje değil.
68
69
69
-
Let's unveil any magic and see what a class really is. That'll help in understanding many complex aspects.
70
+
Hadi, sihri ortaya çıkaralım ve bir sınıfın tam olarak ne olduğunu görelim. Bu daha karmaşık konseptleri anlamamıza da yardımcı olacak.
70
71
71
-
In JavaScript, a class is a kind of a function.
72
+
Javascript'de sınıf aslında bir tür fonksiyondur.
72
73
73
-
Here, take a look:
74
+
Şuna bir göz atalım:
74
75
75
76
```js run
76
77
classUser {
@@ -84,8 +85,8 @@ alert(typeof User); // function
84
85
*/!*
85
86
```
86
87
87
-
What `class User {...}`construct really does is:
88
-
1.Creates a function named `User`, that becomes the result of the class declaration.
88
+
`class User {...}`yapısının yaptığı şey aslında:
89
+
1.`User` adında, sınıfın tanımlayıcısın sonucu olacak, yeni bir fonksiyon oluşturur.
89
90
- The function code is taken from the `constructor` method (assumed empty if we don't write such method).
90
91
3. Stores all methods, such as `sayHi`, in `User.prototype`.
0 commit comments