Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy #137

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Proxy #137

Show file tree
Hide file tree
Changes from all 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
Empty file.
9 changes: 5 additions & 4 deletions 1-js/99-js-misc/01-proxy/article.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Proxy and Reflect

A `Proxy` object 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.
`Proxy` obyekti boshqa obyektni o'rab turadi va xususiyatlarni o'qish/yozish va boshqa operatsiyalarni tutib qolib, ularni boshqarish imkonini beradi. Standart holatda (default) obyekta operatsiyalarni shaffof boshqarishga imkon beradi.

Proxylar ko'p kutubxonalar va ayrim brauzer frameworklarida ishlatilgan. Ushbu bobda biz ko'plab amaliy dasturlarni ko'rib chiqamiz.

Proxies are used in many libraries and some browser frameworks. We'll see many practical applications in this article.

## Proxy

The syntax:
Sintaksis:

```js
let proxy = new Proxy(target, handler)
```

- `target` -- is an object to wrap, can be anything, including functions.
- `target` -- o'rab olish uchun obyekt, har narsa bo'lishi mumkin, funksiya ham.
- `handler` -- proxy configuration: an object with "traps", methods that intercept operations. - e.g. `get` trap for reading a property of `target`, `set` trap for writing a property into `target`, and so on.

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`.
Expand Down