Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

01-proxy#354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
thelordax0 wants to merge1 commit intojavascript-tutorial:master
base:master
Choose a base branch
Loading
fromthelordax0:thelordax0-patch-1
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions1-js/99-js-misc/01-proxy/article.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@

#Proxy and Reflect

A*proxy*wraps another object and intercepts operations, like reading/writing properties and others, optionally handling them on its own, or transparently allowing the object to handle them.
Bir*proxy*başka bir nesneyi sarar ve okuma/yazma özellikleri ve diğerleri gibi işlemleri durdurur, isteğe bağlı olarak bunları kendi başına yönetir veya şeffaf bir şekilde nesnenin bunları işlemesine izin verir.

Proxies are used in many libraries and some browser frameworks. We'll see many practical applications in this chapter.
Proxy'ler birçok kitaplıkta ve bazı tarayıcı çerçevelerinde kullanılır. Bu bölümde birçok pratik uygulama göreceğiz.

The syntax:
Söz dizimi:

```js
let proxy=newProxy(target, handler)
```

-`target` --is an object to wrap, can be anything, including functions.
-`handler` --an object with "traps": methods that intercept operations., e.g.`get` for reading a property,`set` for writing a property, etc.
-`target` --sarılacak bir nesnedir, fonksiyonlar dahil herhangi bir şey olabilir.
-`handler` --'tuzaklara' sahip bir nesne: işlemleri engelleyen yöntemler, ör. Bir özelliği okumak için 'get', bir özelliği yazmak için 'set' vb.

For operations on`proxy`, if there's a corresponding trap in`handler`, then it runs, and the proxy has a chance to handle it, otherwise the operation is performed on`target`.
Proxy üzerinde yapılan işlemlerde, eğer`handler` da buna karşılık gelen bir tuzak varsa çalışır ve`proxy`'nin onu ele alma şansı vardır, aksi takdirde işlem`hedef` üzerinde gerçekleştirilir.

As a starting example, let's create aproxywithout any traps:
Başlangıç ​​örneği olarak herhangi bir tuzak içermeyen birproxyoluşturalım:

```js run
let target= {};
let proxy=newProxy(target, {});//empty handler
let proxy=newProxy(target, {});//boş handler

proxy.test=5;//writing toproxy (1)
alert(target.test);// 5, theproperty appeared in target!
proxy.test=5;// proxy'ye yazıyoruz (1)
alert(target.test);// 5, theözellik hedefte göründü!

alert(proxy.test);// 5,we can read it fromproxy too (2)
alert(proxy.test);// 5,bunuproxy'den de okuyabiliriz (2)

for(let keyin proxy)alert(key);// test,iteration works (3)
for(let keyin proxy)alert(key);// test,iterasyon çalışır (3)
```

As there are no traps, all operations on`proxy` are forwarded to`target`.
`proxy`'de hiç bir tuzak olmadığından`target`'e ilerlenir.

1. A writing operation`proxy.test=` sets the value on`target`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Buraları da çevirebilir misiniz?

2. A reading operation`proxy.test` returns the value from`target`.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp