diff options
author | hochan222 <hochan049@gmail.com> | 2021-07-28 22:06:49 +0900 |
---|---|---|
committer | Kyle <mkitigy@gmail.com> | 2021-08-14 13:40:00 +0900 |
commit | 31fd3596c48ddaf6898c21ed6307545e317a8388 (patch) | |
tree | 84b95a6e33f3e7473883493dccca74cf6fdcfc3a /files | |
parent | cc36a351f91a97c9ad54e64f2d5757cbd5aeed93 (diff) | |
download | translated-content-31fd3596c48ddaf6898c21ed6307545e317a8388.tar.gz translated-content-31fd3596c48ddaf6898c21ed6307545e317a8388.tar.bz2 translated-content-31fd3596c48ddaf6898c21ed6307545e317a8388.zip |
@hochan222
feat: convert html to markdown, Enumerability_and_ownership_of_properties
Diffstat (limited to 'files')
-rw-r--r-- | files/ko/web/javascript/enumerability_and_ownership_of_properties/index.md | 626 |
1 files changed, 381 insertions, 245 deletions
diff --git a/files/ko/web/javascript/enumerability_and_ownership_of_properties/index.md b/files/ko/web/javascript/enumerability_and_ownership_of_properties/index.md index 41252c39d1..8f4155cf84 100644 --- a/files/ko/web/javascript/enumerability_and_ownership_of_properties/index.md +++ b/files/ko/web/javascript/enumerability_and_ownership_of_properties/index.md @@ -1,173 +1,308 @@ --- title: Enumerability and ownership of properties slug: Web/JavaScript/Enumerability_and_ownership_of_properties +tags: + - Guide + - JavaScript translation_of: Web/JavaScript/Enumerability_and_ownership_of_properties --- -<div>{{JsSidebar("More")}}</div> +{{JsSidebar("More")}} +'Enumerable properties'(열거 가능한 속성)는 내부 열거 형 플래그가 true로 설정된 property로, 이는 간단한 할당 또는 property initializer ([Object.defineProperty](/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty)를 통해 정의 된 특성 및 이러한 기본 열거 형을 false로 정의한 특성)를 통해 작성된 property의 기본값입니다. +등록 정보의 키가 [Symbol](/ko/docs/Web/JavaScript/Reference/Global_Objects/Symbol)이 아니면 열거 가능한 등록 정보가 [for...in](/ko/docs/Web/JavaScript/Reference/Statements/for...in) 루프에 표시됩니다. 'Ownership of properties' (속성의 소유권)은 속성이 프로토 타입 체인이 아닌 개체에 직접 속하는지 여부에 따라 결정됩니다. 객체의 속성도 전체적으로 검색 할 수 있습니다. 개체 속성을 감지, 반복 / 열거 및 검색하는 여러 가지 기본 제공 방법이 있으며 아래 표와 같이 사용할 수 있습니다. 누락 된 범주를 얻는 방법을 보여주는 샘플 코드는 다음과 같습니다. -<p>'Enumerable properties'(열거 가능한 속성)는 내부 열거 형 플래그가 true로 설정된 property로, 이는 간단한 할당 또는 property initializer (<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty">Object.defineProperty</a>를 통해 정의 된 특성 및 이러한 기본 열거 형을 false로 정의한 특성)를 통해 작성된 property의 기본값입니다. 등록 정보의 키가 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol">Symbol</a>이 아니면 열거 가능한 등록 정보가 <a href="/en-US/docs/Web/JavaScript/Reference/Statements/for...in">for...in</a> 루프에 표시됩니다. 'Ownership of properties' (속성의 소유권)은 속성이 프로토 타입 체인이 아닌 개체에 직접 속하는지 여부에 따라 결정됩니다. 객체의 속성도 전체적으로 검색 할 수 있습니다. 개체 속성을 감지, 반복 / 열거 및 검색하는 여러 가지 기본 제공 방법이 있으며 아래 표와 같이 사용할 수 있습니다. 누락 된 범주를 얻는 방법을 보여주는 샘플 코드는 다음과 같습니다.</p> +## 객체 속성 감지, 검색 및 열거 -<div style="overflow: auto; width: 100%;"> -<table> - <caption>Property enumerability and ownership - built-in methods of detection, retrieval, and iteration</caption> - <tbody> - <tr> - <th>Functionality</th> - <th>Own object</th> - <th>Own object and its prototype chain</th> - <th>Prototype chain only</th> - </tr> - <tr> - <td>Detection</td> - <td> - <table> - <thead> - <tr> - <th scope="col">Enumerable</th> - <th scope="col">Nonenumerable</th> - <th scope="col">Enumerable and Nonenumerable</th> - </tr> - </thead> - <tbody> - <tr> - <td> - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable">propertyIsEnumerable</a></code></p> - - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty">hasOwnProperty</a></code></p> - </td> - <td> - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty">hasOwnProperty</a></code> – filtered to exclude enumerables using <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable">propertyIsEnumerable</a></code></p> - </td> - <td><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty">hasOwnProperty</a></code></td> - </tr> - </tbody> - </table> - </td> - <td> - <table> - <thead> - <tr> - <th scope="col">Enumerable</th> - <th scope="col">Nonenumerable</th> - <th scope="col">Enumerable and Nonenumerable</th> - </tr> - </thead> - <tbody> - <tr> - <td>Not available without extra code</td> - <td>Not available without extra code</td> - <td><code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/in">in</a></code></td> - </tr> - </tbody> - </table> - </td> - <td>Not available without extra code</td> - </tr> - <tr> - <td>Retrieval</td> - <td> - <table> - <thead> - <tr> - <th scope="col">Enumerable</th> - <th scope="col">Nonenumerable</th> - <th scope="col">Enumerable and Nonenumerable</th> - </tr> - </thead> - <tbody> - <tr> - <td> - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys">Object.keys</a></code></p> - - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames">getOwnPropertyNames</a></code> </p> +개체 속성을 감지, 반복/열거 및 검색하는 여러 가지 기본 제공 수단이 있습니다. 아래 표에 요약되어 있습니다. - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols">getOwnPropertySymbols</a></code></p> - </td> - <td><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames">getOwnPropertyNames</a></code>, <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols">getOwnPropertySymbols</a> </code>– filtered to exclude enumerables using <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable">propertyIsEnumerable</a></code></td> - <td> - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames">getOwnPropertyNames</a></code></p> +### Detection - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols">getOwnPropertySymbols</a></code></p> - </td> - </tr> - </tbody> - </table> - </td> - <td>Not available without extra code</td> - <td>Not available without extra code</td> - </tr> - <tr> - <td>Iterable</td> - <td> - <table> - <thead> - <tr> - <th scope="col">Enumerable</th> - <th scope="col">Nonenumerable</th> - <th scope="col">Enumerable and Nonenumerable</th> - </tr> - </thead> - <tbody> - <tr> - <td> - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys">Object.keys</a></code></p> +<table> + <thead> + <tr> + <th></th> + <th>Own object</th> + <th>Own object and prototype chain</th> + <th>Prototype chain only</th> + </tr> + </thead> + <tbody> + <tr> + <th>Enumerable</th> + <td> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable" + >propertyIsEnumerable</a + ></code + > + </p> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty" + >hasOwnProperty</a + ></code + > + </p> + </td> + <td>Not available without extra code</td> + <td>Not available without extra code</td> + </tr> + <tr> + <th>Nonenumerable</th> + <td> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty" + >hasOwnProperty</a + ></code + > + – filtered to exclude enumerables using + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable" + >propertyIsEnumerable</a + ></code + > + </p> + </td> + <td>Not available without extra code</td> + <td>Not available without extra code</td> + </tr> + <tr> + <th>Enumerable and Nonenumerable</th> + <td> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty" + >hasOwnProperty</a + ></code + > + </p> + </td> + <td> + <code + ><a href="/ko/docs/Web/JavaScript/Reference/Operators/in" + >in</a + ></code + > + </td> + <td>Not available without extra code</td> + </tr> + </tbody> +</table> - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames">getOwnPropertyNames</a></code> </p> +### Retrieval - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols">getOwnPropertySymbols</a></code></p> - </td> - <td><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames">getOwnPropertyNames</a></code>, <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols">getOwnPropertySymbols</a></code> – filtered to exclude enumerables using <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable">propertyIsEnumerable</a></code></td> - <td> - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames">getOwnPropertyNames</a></code></p> +<table> + <thead> + <tr> + <th></th> + <th>Own object</th> + <th>Own object and prototype chain</th> + <th>Prototype chain only</th> + </tr> + </thead> + <tbody> + <tr> + <th>Enumerable</th> + <td> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/keys" + >Object.keys</a + ></code + > + </p> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames" + >getOwnPropertyNames</a + ></code + > + </p> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols" + >getOwnPropertySymbols</a + ></code + > + </p> + </td> + <td>Not available without extra code</td> + <td>Not available without extra code</td> + </tr> + <tr> + <th>Nonenumerable</th> + <td> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames" + >getOwnPropertyNames</a + ></code + >, + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols" + >getOwnPropertySymbols</a + ></code + > + – filtered to exclude enumerables using <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable" + >propertyIsEnumerable</a + ></code + > + </td> + <td>Not available without extra code</td> + <td>Not available without extra code</td> + </tr> + <tr> + <th>Enumerable and Nonenumerable</th> + <td> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames" + >getOwnPropertyNames</a + ></code + > + </p> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols" + >getOwnPropertySymbols</a + ></code + > + </p> + </td> + <td>Not available without extra code</td> + <td>Not available without extra code</td> + </tr> + </tbody> +</table> - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols">getOwnPropertySymbols</a></code></p> - </td> - </tr> - </tbody> - </table> - </td> - <td> - <table> - <thead> - <tr> - <th scope="col">Enumerable</th> - <th scope="col">Nonenumerable</th> - <th scope="col">Enumerable and Nonenumerable</th> - </tr> - </thead> - <tbody> - <tr> - <td> - <p><code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/for...in">for..in</a></code></p> +### Iteration +<table> + <thead> + <tr> + <th></th> + <th>Own object</th> + <th>Own object and prototype chain</th> + <th>Prototype chain only</th> + </tr> + </thead> + <tbody> + <tr> + <th>Enumerable</th> + <td> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/keys" + >Object.keys</a + ></code + > + </p> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames" + >getOwnPropertyNames</a + ></code + > + </p> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols" + >getOwnPropertySymbols</a + ></code + > + </p> + </td> + <td> + <p> + <code + ><a href="/ko/docs/Web/JavaScript/Reference/Statements/for...in" + >for..in</a + ></code + > + </p> <p>(excluding symbols)</p> - </td> - <td>Not available without extra code</td> - <td>Not available without extra code</td> - </tr> - </tbody> - </table> - </td> - <td>Not available without extra code</td> - </tr> - </tbody> + </td> + <td>Not available without extra code</td> + </tr> + <tr> + <th>Nonenumerable</th> + <td> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames" + >getOwnPropertyNames</a + ></code + >, + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols" + >getOwnPropertySymbols</a + ></code + > + – filtered to exclude enumerables using <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable" + >propertyIsEnumerable</a + ></code + > + </td> + <td>Not available without extra code</td> + <td>Not available without extra code</td> + </tr> + <tr> + <th>Enumerable and Nonenumerable</th> + <td> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames" + >getOwnPropertyNames</a + ></code + > + </p> + <p> + <code + ><a + href="/ko/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols" + >getOwnPropertySymbols</a + ></code + > + </p> + </td> + <td>Not available without extra code</td> + <td>Not available without extra code</td> + </tr> + </tbody> </table> -</div> - -<h2 id="Obtaining_properties_by_enumerabilityownership">Obtaining properties by enumerability/ownership</h2> - +## Obtaining properties by enumerability/ownership -<p>아래는 모든 경우에 가장 효율적인 알고리즘은 아니지만 빠르게 코드를 작성하여 확인하기 좋습니다.</p> +아래는 모든 경우에 가장 효율적인 알고리즘은 아니지만 빠르게 코드를 작성하여 확인하기 좋습니다. -<ul> - <li>Detection can occur by <code>SimplePropertyRetriever.theGetMethodYouWant(obj).indexOf(prop) > -1</code></li> - <li>Iteration can occur by <code>SimplePropertyRetriever.theGetMethodYouWant(obj).forEach(function (value, prop) {});</code> (or use<code> filter()</code>, <code>map()</code>, etc.)</li> -</ul> +- Detection can occur by `SimplePropertyRetriever.theGetMethodYouWant(obj).indexOf(prop) > -1` +- Iteration can occur by `SimplePropertyRetriever.theGetMethodYouWant(obj).forEach(function (value, prop) {});` (or use` filter()`, `map()`, etc.) -<pre class="brush: js notranslate">var SimplePropertyRetriever = { +```js +var SimplePropertyRetriever = { getOwnEnumerables: function(obj) { return this._getPropertyNames(obj, true, false, this._enumerable); // Or could use for..in filtered with hasOwnProperty or just this: return Object.keys(obj); @@ -215,7 +350,7 @@ translation_of: Web/JavaScript/Enumerability_and_ownership_of_properties do { if (iterateSelfBool) { Object.getOwnPropertyNames(obj).forEach(function(prop) { - if (props.indexOf(prop) === -1 && includePropCb(obj, prop)) { + if (props.indexOf(prop) === -1 && includePropCb(obj, prop)) { props.push(prop); } }); @@ -228,104 +363,105 @@ translation_of: Web/JavaScript/Enumerability_and_ownership_of_properties return props; } -};</pre> +}; +``` -<h2 id="Detection_Table">Detection Table</h2> +## Detection Table -<div style="overflow: auto; width: 100%;"> <table> - <thead> - <tr> - <th scope="row"></th> - <th scope="col"><code>in</code></th> - <th scope="col"><code>for..in</code></th> - <th scope="col"><code>obj.hasOwnProperty</code></th> - <th scope="col"><code>obj.propertyIsEnumerable</code></th> - <th scope="col"><code>Object.keys</code></th> - <th scope="col"><code>Object.getOwnPropertyNames</code></th> - <th scope="col"><code>Object.getOwnPropertyDescriptors</code></th> - <th scope="col"><code>Reflect.ownKeys()</code></th> - </tr> - </thead> - <tbody> - <tr> - <th scope="row">Enumerable</th> - <td>true</td> - <td>true</td> - <td>true</td> - <td>true</td> - <td>true</td> - <td>true</td> - <td>true</td> - <td>true</td> - </tr> - <tr> - <th scope="row">Nonenumerable</th> - <td>true</td> - <td>false</td> - <td>true</td> - <td>false</td> - <td>false</td> - <td>true</td> - <td>true</td> - <td>true</td> - </tr> - <tr> - <th scope="row">Symbols keys</th> - <td>true</td> - <td>false</td> - <td>true</td> - <td>true</td> - <td>false</td> - <td>false</td> - <td>true</td> - <td>true</td> - </tr> - <tr> - <th scope="row">Inherited Enumerable</th> - <td>true</td> - <td>true</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - </tr> - <tr> - <th scope="row">Inherited Nonenumerable</th> - <td>true</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - </tr> - <tr> - <th scope="row">Inherited Symbols keys</th> - <td>true</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - <td>false</td> - </tr> - </tbody> + <thead> + <tr> + <th></th> + <th>Enumerable</th> + <th>Nonenumerable</th> + <th>Symbols keys</th> + <th>Inherited Enumerable</th> + <th>Inherited Nonenumerable</th> + <th>Inherited Symbols keys</th> + </tr> + </thead> + <tbody> + <tr> + <th><code>in</code></th> + <td>true</td> + <td>true</td> + <td>true</td> + <td>true</td> + <td>true</td> + <td>true</td> + </tr> + <tr> + <th><code>for..in</code></th> + <td>true</td> + <td>false</td> + <td>false</td> + <td>true</td> + <td>false</td> + <td>false</td> + </tr> + <tr> + <th><code>obj.hasOwnProperty</code></th> + <td>true</td> + <td>true</td> + <td>true</td> + <td>false</td> + <td>false</td> + <td>false</td> + </tr> + <tr> + <th><code>obj.propertyIsEnumerable</code></th> + <td>true</td> + <td>false</td> + <td>true</td> + <td>false</td> + <td>false</td> + <td>false</td> + </tr> + <tr> + <th><code>Object.keys</code></th> + <td>true</td> + <td>false</td> + <td>false</td> + <td>false</td> + <td>false</td> + <td>false</td> + </tr> + <tr> + <th><code>Object.getOwnPropertyNames</code></th> + <td>true</td> + <td>true</td> + <td>false</td> + <td>false</td> + <td>false</td> + <td>false</td> + </tr> + <tr> + <th><code>Object.getOwnPropertyDescriptors</code></th> + <td>true</td> + <td>true</td> + <td>true</td> + <td>false</td> + <td>false</td> + <td>false</td> + </tr> + <tr> + <th><code>Reflect.ownKeys()</code></th> + <td>true</td> + <td>true</td> + <td>true</td> + <td>false</td> + <td>false</td> + <td>false</td> + </tr> + </tbody> </table> -</div> -<h2 id="See_also">See also</h2> +## 같이보기 -<ul> - <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/in">in</a></code></li> - <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/for...in">for..in</a></code></li> - <li>{{jsxref("Object.hasOwnProperty()")}}</li> - <li>{{jsxref("Object.propertyIsEnumerable()")}}</li> - <li>{{jsxref("Object.getOwnPropertyNames()")}}</li> - <li>{{jsxref("Object.keys()")}}</li> - <li>{{jsxref("Object.getOwnPropertyDescriptors()")}}</li> -</ul> +- [`in`](/ko/docs/Web/JavaScript/Reference/Operators/in) +- [`for..in`](/ko/docs/Web/JavaScript/Reference/Statements/for...in) +- {{jsxref("Object.hasOwnProperty()")}} +- {{jsxref("Object.propertyIsEnumerable()")}} +- {{jsxref("Object.getOwnPropertyNames()")}} +- {{jsxref("Object.keys()")}} +- {{jsxref("Object.getOwnPropertyDescriptors()")}} |