Skip to content

Commit de734c9

Browse files
authored
Merge pull request #193 from thePhenom21/patch-1
Class basic syntax
2 parents f62670c + dc31296 commit de734c9

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

1-js/09-classes/01-class/article.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11

2-
# Class basic syntax
2+
# Temel Sınıf sözdizimi
33

44
```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.
66
```
77

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.
99

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.
1111

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.
1313

14-
## The "class" syntax
14+
## Sınıf sözdizimi
1515

16-
The basic syntax is:
16+
Temel sözdizimi:
1717
```js
1818
class MyClass {
1919
// class methods
@@ -25,11 +25,11 @@ class MyClass {
2525
}
2626
```
2727

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.
2929

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.
3131

32-
For example:
32+
Örnek olarak:
3333

3434
```js run
3535
class User {
@@ -49,28 +49,29 @@ let user = new User("John");
4949
user.sayHi();
5050
```
5151

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.
5555

56-
...Then we can call methods, such as `user.sayHi`.
5756

57+
...Daha sonra `user.sayHi` gibi metodları çağırabiliriz.
5858

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.
6159

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.
6364
```
6465

65-
## What is a class?
66+
## Sınıf nedir?
6667

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.
6869

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.
7071

71-
In JavaScript, a class is a kind of a function.
72+
Javascript'de sınıf aslında bir tür fonksiyondur.
7273

73-
Here, take a look:
74+
Şuna bir göz atalım:
7475

7576
```js run
7677
class User {
@@ -84,8 +85,8 @@ alert(typeof User); // function
8485
*/!*
8586
```
8687

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.
8990
- The function code is taken from the `constructor` method (assumed empty if we don't write such method).
9091
3. Stores all methods, such as `sayHi`, in `User.prototype`.
9192

0 commit comments

Comments
 (0)