# Proxy 객체 활용하기

Proxy 객체 언제 사용하면 좋을까? 👉🏻 ***객체의 없는 속성들에 접근하면 undefined가 아닌 에러를 내보내고 싶을 때***

```javascript
const o = { foo: 'bar' };
const p = new Proxy(o, {
  get(target, prop) {
    if (prop in target) {
      return target[prop];
    }
    throw new Error(`${prop} 존재x`);
  },
});
```

<figure><img src="/files/jUGCn2pBXUk8nN5T8raP" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://leejaelll.gitbook.io/dev_jaell/javascript/proxy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
