diff options
Diffstat (limited to 'files/ko/web/javascript/reference')
8 files changed, 0 insertions, 928 deletions
diff --git a/files/ko/web/javascript/reference/functions/arguments/caller/index.html b/files/ko/web/javascript/reference/functions/arguments/caller/index.html deleted file mode 100644 index bcdc54c7dc..0000000000 --- a/files/ko/web/javascript/reference/functions/arguments/caller/index.html +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: arguments.caller -slug: Web/JavaScript/Reference/Functions/arguments/caller -translation_of: Archive/Web/JavaScript/arguments.caller ---- -<div>{{jsSidebar("Functions")}}</div> - -<p>이전의 <strong><code>arguments.caller</code></strong> 속성은 현재 실행한 함수를 적용하여 제공했었습니다. 이 속성은 삭제되었으며 더 이상 작동하지 않습니다.</p> - -<h2 id="설명">설명</h2> - -<p>이 속성은 더 이상 이용할 수 없습니다. 하지만 {{jsxref("Function.caller")}} 는 사용할 수 있습니다.</p> - -<pre class="brush: js">function whoCalled() { - if (whoCalled.caller == null) - console.log('I was called from the global scope.'); - else - console.log(whoCalled.caller + ' called me!'); -}</pre> - -<h2 id="예">예</h2> - -<p>다음의 코드는 함수 내에서 <code>arguments.caller </code>값을 확인하기 위해 사용되었지만, 더 이상 작동하지 않습니다.</p> - -<pre class="brush: js example-bad">function whoCalled() { - if (arguments.caller == null) - console.log('I was called from the global scope.'); - else - console.log(arguments.caller + ' called me!'); -} -</pre> - -<h2 id="스펙">스펙</h2> - -<p>초기 정의된 부분이 아닙니다. JavaScript 1.1에서 구현되었으며, 잠재적인 보안 취약의 우려로 ({{bug(7224)}}) 삭제되었습니다.</p> - -<h2 id="브라우저_호환성">브라우저 호환성</h2> - -<p>{{CompatibilityTable}}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<h2 id="참조">참조</h2> - -<ul> - <li>{{jsxref("Function")}}</li> -</ul> diff --git a/files/ko/web/javascript/reference/global_objects/array/observe/index.html b/files/ko/web/javascript/reference/global_objects/array/observe/index.html deleted file mode 100644 index 015ae049c5..0000000000 --- a/files/ko/web/javascript/reference/global_objects/array/observe/index.html +++ /dev/null @@ -1,87 +0,0 @@ ---- -title: Array.observe() -slug: Web/JavaScript/Reference/Global_Objects/Array/observe -tags: - - Array - - JavaScript - - Method - - Obsolete -translation_of: Archive/Web/JavaScript/Array.observe ---- -<div>{{JSRef}} {{obsolete_header}}</div> - -<p><strong><code>Array.observe()</code> </strong>메서드는 {{jsxref("Object.observe()")}}가 객체를 관찰하는 것과 비슷하게 , 배열의 변화를 비동기 적으로 관찰 하는데 사용 되었습니다. <font face="Consolas, Liberation Mono, Courier, monospace">그것은 </font>발생 순서에 따른 변화의 흐름을 제공합니다. <code>Object.observe()</code>가 accept type list <code>["add", "update", "delete", "splice"]</code>와 함께 호출되는 것과 같습니다. 하지만 이 API는 더이상 사용되지 않고 브라우저에서 제거 되었습니다. 대신, 더 일반적인 {{jsxref("Proxy")}} 객체를 사용하세요.</p> - -<h2 id="구문">구문</h2> - -<pre class="syntaxbox">Array.observe(<var>arr</var>, <var>callback</var>)</pre> - -<h3 id="매개변수">매개변수</h3> - -<dl> - <dt><code>arr</code></dt> - <dd>관찰 할 배열</dd> - <dt><code>callback</code></dt> - <dd>이 함수는 변화가 일어날때 마다 다음과 같은 인수와 함께 호출됩니다. - <dl> - <dt><code>changes</code></dt> - <dd>변경을 나타내는 각 객체들의 배열입니다. 이 변경 객체들의 프로퍼티 들은: - <ul> - <li><strong><code>name</code></strong>: 변경된 프로퍼티의 이름</li> - <li><strong><code>object</code></strong>: 변경 후 배열</li> - <li><strong><code>type</code></strong>: 변경 타입을 나타내는 문자. <code>"add"</code>, <code>"update"</code>, <code>"delete"</code>, 또는 <code>"splice" 중 하나</code>.</li> - <li><strong><code>oldValue</code></strong>: <code>"update"</code> 나 <code>"delete"유형에만 해당합니다. 변경 전 값</code>.</li> - <li><strong><code>index</code></strong>: <code>"splice"유형에만 해당합니다</code>. 변경이 발생한 인덱스.</li> - <li><strong><code>removed</code></strong>: <code>"splice"유형에만 해당합니다</code>. 삭제 된 요소들의 배열.</li> - <li><strong><code>addedCount</code></strong>: <code>"splice"유형에만 해당합니다</code>. 추가 된 요소들의 숫자.</li> - </ul> - </dd> - </dl> - </dd> -</dl> - -<h2 id="설명">설명</h2> - -<p>콜백 함수는 arr이 변경 될 때마다 호출되며 발생하는 순서대로 모든 변경 사항의 배열로 호출됩니다</p> - -<div class="note"> -<p><code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop">Array.prototype.pop()</a>이</code> <code>"splice"</code> 변경으로 보고되는 것처럼, 변경은 배열 메서드를 통해 일어납니다. 배열 길이를 변경하지 않는 인덱스 할당 변경은 "update" 변경으로 보고 될 수 있습니다.</p> -</div> - -<h2 id="예제">예제</h2> - -<h3 id="다른_변경_유형_로깅(Logging)">다른 변경 유형 로깅(Logging)</h3> - -<pre class="brush: js">var arr = ['a', 'b', 'c']; - -Array.observe(arr, function(changes) { - console.log(changes); -}); - -arr[1] = 'B'; -// [{type: 'update', object: <arr>, name: '1', oldValue: 'b'}] - -arr[3] = 'd'; -// [{type: 'splice', object: <arr>, index: 3, removed: [], addedCount: 1}] - -arr.splice(1, 2, 'beta', 'gamma', 'delta'); -// [{type: 'splice', object: <arr>, index: 1, removed: ['B', 'c'], addedCount: 3}] -</pre> - -<h2 id="명세">명세</h2> - -<p><a href="https://github.com/arv/ecmascript-object-observe">Strawman proposal specification</a>.</p> - -<h2 id="브라우저_호환성">브라우저 호환성</h2> - - - -<p>{{Compat("javascript.builtins.Array.observe")}}</p> - -<h2 id="같이_보기">같이 보기</h2> - -<ul> - <li><a href="//stackoverflow.com/q/29269057/778272">Under what condition would Array.observe's “add” event trigger?</a></li> - <li>{{jsxref("Array.unobserve()")}} {{obsolete_inline}}</li> - <li>{{jsxref("Object.observe()")}} {{obsolete_inline}}</li> -</ul> diff --git a/files/ko/web/javascript/reference/global_objects/object/observe/index.html b/files/ko/web/javascript/reference/global_objects/object/observe/index.html deleted file mode 100644 index bf3b004d8c..0000000000 --- a/files/ko/web/javascript/reference/global_objects/object/observe/index.html +++ /dev/null @@ -1,193 +0,0 @@ ---- -title: Object.observe() -slug: Web/JavaScript/Reference/Global_Objects/Object/observe -tags: - - 감시 객체 -translation_of: Archive/Web/JavaScript/Object.observe ---- -<div>{{JSRef}}</div> - -<p><strong><code>Object.observe()</code></strong> 메소드는 객체의 변화를 비동기로 감시하는데에 사용된다. 이 메소드는 변화들이 발생한 순서대로 그 흐름을 제공한다.</p> - -<h2 id="문법">문법</h2> - -<pre class="syntaxbox"><code>Object.observe(<var>obj</var>, <var>callback</var>[, <var>acceptList</var>])</code></pre> - -<h3 id="파라미터">파라미터</h3> - -<dl> - <dt><code>obj</code></dt> - <dd>감시될 객체입니다.</dd> - <dt><code>callback</code></dt> - <dd><code>obj</code>의 변경이 일어났을 때마다 호출될 함수입니다. 다음과 같은 인자를 갖습니다. - <dl> - <dt><code>changes</code></dt> - <dd>변경 사항을 나타내는 객체의 배열입니다. 그 객체의 프로퍼티는 다음과 같습니다. - <ul> - <li><strong><code>name</code></strong>: 변경된 프로퍼티의 이름입니다.</li> - <li><strong><code>object</code></strong>: 변경이 일어난 뒤의 객체입니다.</li> - <li><strong><code>type</code></strong>: 변경의 종류를 의미하는 string입니다. <code>"add"</code>, <code>"update"</code>, <code>"delete"</code> 중 하나입니다.</li> - <li><strong><code>oldValue</code></strong>: 변경되기 이전의 값입니다. <code>"update"와</code> <code>"delete"</code> 타입에만 존재합니다.</li> - </ul> - </dd> - </dl> - </dd> - <dt><code>acceptList</code></dt> - <dd>감시할 변경의 종류를 의미하는 리스트입니다. 주어지지 않은 경우, 배열 <code>["add", "update", "delete", "reconfigure", "setPrototype", "preventExtensions"]</code> 이 이용될 것입니다.</dd> -</dl> - -<h2 id="설명">설명</h2> - -<p><code>callback</code>은 <code>obj</code>에 변경이 있을 때마다 실행되며, 모든 변경 사항이 일어난 순서대로 담긴 배열이 전달됩니다.</p> - -<h2 id="예제">예제</h2> - -<h3 id="Logging_all_six_different_types">Logging all six different types</h3> - -<pre class="brush: js">var obj = { - foo: 0, - bar: 1 -}; - -Object.observe(obj, function(changes) { - console.log(changes); -}); - -obj.baz = 2; -// [{name: 'baz', object: <obj>, type: 'add'}] - -obj.foo = 'hello'; -// [{name: 'foo', object: <obj>, type: 'update', oldValue: 0}] - -delete obj.baz; -// [{name: 'baz', object: <obj>, type: 'delete', oldValue: 2}] - -Object.defineProperty(obj, 'foo', {writable: false}); -// [{name: 'foo', object: <obj>, type: 'reconfigure'}] - -Object.setPrototypeOf(obj, {}); -// [{name: '__proto__', object: <obj>, type: 'setPrototype', oldValue: <prototype>}] - -Object.seal(obj); -// [ -// {name: 'foo', object: <obj>, type: 'reconfigure'}, -// {name: 'bar', object: <obj>, type: 'reconfigure'}, -// {object: <obj>, type: 'preventExtensions'} -// ] -</pre> - -<h3 id="데이터_바인딩">데이터 바인딩</h3> - -<pre class="brush: js">// A user model -var user = { - id: 0, - name: 'Brendan Eich', - title: 'Mr.' -}; - -// Create a greeting for the user -function updateGreeting() { - user.greeting = 'Hello, ' + user.title + ' ' + user.name + '!'; -} -updateGreeting(); - -Object.observe(user, function(changes) { - changes.forEach(function(change) { - // Any time name or title change, update the greeting - if (change.name === 'name' || change.name === 'title') { - updateGreeting(); - } - }); -}); -</pre> - -<h3 id="Custom_change_type">Custom change type</h3> - -<pre class="brush: js">// A point on a 2D plane -var point = {x: 0, y: 0, distance: 0}; - -function setPosition(pt, x, y) { - // Performing a custom change - Object.getNotifier(pt).performChange('reposition', function() { - var oldDistance = pt.distance; - pt.x = x; - pt.y = y; - pt.distance = Math.sqrt(x * x + y * y); - return {oldDistance: oldDistance}; - }); -} - -Object.observe(point, function(changes) { - console.log('Distance change: ' + (point.distance - changes[0].oldDistance)); -}, ['reposition']); - -setPosition(point, 3, 4); -// Distance change: 5 -</pre> - -<h2 id="Specifications">Specifications</h2> - -<p><a href="https://github.com/arv/ecmascript-object-observe">Strawman proposal for ECMAScript 7</a>.</p> - -<h2 id="브라우저_호환성">브라우저 호환성</h2> - -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome("36")}}</td> - <td>{{CompatNo}} [1]</td> - <td>{{CompatNo}} [2]</td> - <td>{{CompatOpera("23")}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome("36")}}</td> - <td>{{CompatNo}} [1]</td> - <td>{{CompatNo}} [2]</td> - <td>{{CompatOpera("23")}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1]: See {{bug(800355)}}</p> - -<p>[2]: See relevant <a href="https://dev.modern.ie/platform/status/objectobserve/">MS Edge platform status entry</a></p> - -<h2 id="같이_보기">같이 보기</h2> - -<ul> - <li>{{jsxref("Object.unobserve()")}} {{experimental_inline}}</li> - <li>{{jsxref("Array.observe()")}} {{experimental_inline}}</li> -</ul> diff --git a/files/ko/web/javascript/reference/liveconnect/index.html b/files/ko/web/javascript/reference/liveconnect/index.html deleted file mode 100644 index dfa43d52d0..0000000000 --- a/files/ko/web/javascript/reference/liveconnect/index.html +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: LiveConnect -slug: Web/JavaScript/Reference/LiveConnect -translation_of: Archive/Web/LiveConnect ---- -<p>이 절(section)은 생성자, 메소드와 함께 LiveConnect에 쓰이는 Java 클래스를 상세히 기록합니다. 이 클래스들은 Java 객체가 JavaScript 코드에 접근할 수 있게 합니다.</p> -<p><a href="ko/Core_JavaScript_1.5_Reference/LiveConnect/JSException">JSException</a></p> -<dl> - <dd> - public 클래스 <code>JSException</code>은 <code>RuntimeException</code>를 상속하고, JavaScript가 에러를 반환하면 발생됩니다.</dd> -</dl> -<p><a href="ko/Core_JavaScript_1.5_Reference/LiveConnect/JSObject">JSObject</a></p> -<dl> - <dd> - public 클래스 <code>JSObject</code>는 <code>Object</code>를 상속합니다. JavaScript 개체는 클래스 <code>JSObject</code>의 인스턴스(instance)로 싸여 Java가 JavaScript 개체를 다루게 하도록 Java에 건네집니다.</dd> -</dl> -<p>{{ languages( { "en": "en/Core_JavaScript_1.5_Reference/LiveConnect", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/LiveConnect" } ) }}</p> diff --git a/files/ko/web/javascript/reference/operators/expression_closures/index.html b/files/ko/web/javascript/reference/operators/expression_closures/index.html deleted file mode 100644 index bf44be6cd7..0000000000 --- a/files/ko/web/javascript/reference/operators/expression_closures/index.html +++ /dev/null @@ -1,79 +0,0 @@ ---- -title: 표현식 클로저 -slug: Web/JavaScript/Reference/Operators/Expression_closures -tags: - - Function - - JavaScript - - Non-standard - - Obsolete - - Operator - - Reference -translation_of: Archive/Web/JavaScript/Expression_closures ---- -<div>{{JSSidebar("Operators")}}{{Non-standard_Header}}{{Obsolete_Header("gecko60")}} -<div class="warning"><strong>Non-standard. Do not use!</strong><br> -The expression closure syntax is a deprecated Firefox-specific feature and has been removed starting with Firefox 60. For future-facing usages, consider using <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">arrow functions</a>.</div> -</div> - -<p>클로져는 간단한 함수를 작성하기 위한 짧은 함수구문 입니다.</p> - -<h2 id="Syntax">Syntax</h2> - -<pre class="syntaxbox">function [<em>name</em>]([<em>param1</em>[, <em>param2[</em>, ..., <em>paramN</em>]]]) - <em>expression</em> -</pre> - -<h3 id="Parameters">Parameters</h3> - -<dl> - <dt><code>name</code></dt> - <dd>함수의 이름입니다. 익명함수의 경우에는 생략할 수 있습니다. 이름은 함수본문에만 국한됩니다.</dd> - <dt><code>paramN</code></dt> - <dd>함수에 전달할 인수의 이름입니다. 함수는 최대 255개의 인수를 가질 수 있습니다.</dd> - <dt><code>expression</code></dt> - <dd>함수의 본문을 구성하는 표현식입니다.</dd> -</dl> - -<h2 id="Description">Description</h2> - -<p>이 추가적인 기능은 <a class="external" href="http://en.wikipedia.org/wiki/Lambda_calculus#Lambda_calculus_and_programming_languages">람다 표기법</a>과 비슷한 언어를 제공하기위해 간단한 기능을 작성하는데 필요한 단축형일 뿐입니다.</p> - -<p>JavaScript 1.7 and older:</p> - -<pre class="brush: js">function(x) { return x * x; }</pre> - -<p>JavaScript 1.8:</p> - -<pre class="brush: js">function(x) x * x</pre> - -<p>이 구문을 사용하면 중괄호나 'return'문을 생략하여 암시적으로 만들 수 있습니다. 코드를 더 짧게 만들 수 있는 것 이외의 이방법으로 얻을 수 있는 추가 이점은 없습니다.</p> - -<h2 id="Examples">Examples</h2> - -<p>바인딩 이벤트 리스너의 간단한 예제:</p> - -<pre class="brush: js"> document.addEventListener('click', function() false, true); -</pre> - -<p>JavaScript 1.6의 일부 배열 함수에 이 표기법을 사용합니다:</p> - -<pre class="brush: js">elems.some(function(elem) elem.type == 'text'); -</pre> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - - - -<p>{{Compat("javascript.operators.expression_closures")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{jsxref("Functions_and_function_scope", "Functions and function scope")}}</li> - <li>{{jsxref("Function")}}</li> - <li>{{jsxref("Statements/function", "function statement")}}</li> - <li>{{jsxref("Operators/function", "function expression")}}</li> - <li>{{jsxref("Statements/function*", "function* statement")}}</li> - <li>{{jsxref("Operators/function*", "function* expression")}}</li> - <li>{{jsxref("GeneratorFunction")}}</li> -</ul> diff --git a/files/ko/web/javascript/reference/operators/generator_comprehensions/index.html b/files/ko/web/javascript/reference/operators/generator_comprehensions/index.html deleted file mode 100644 index 927b613dc6..0000000000 --- a/files/ko/web/javascript/reference/operators/generator_comprehensions/index.html +++ /dev/null @@ -1,174 +0,0 @@ ---- -title: 생성기 내포 -slug: Web/JavaScript/Reference/Operators/Generator_comprehensions -tags: - - JavaScript - - Non-standard - - Obsolete - - Reference -translation_of: Archive/Web/JavaScript/Generator_comprehensions ---- -<div>{{JSSidebar("Operators")}}{{Non-standard_Header}}{{Obsolete_Header("gecko58")}} -<div class="blockIndicator warning"> -<p><strong>Non-standard. Do not use!</strong><br> - The generator comprehensions syntax is non-standard and removed starting with Firefox 58. For future-facing usages, consider using {{JSxRef("Statements/function*", "generator", "", 1)}}.</p> -</div> -</div> - -<p>The <strong>generator comprehension</strong> syntax was a JavaScript expression which allowed you to quickly assemble a new generator function based on an existing iterable object. However, it has been removed from the standard and the Firefox implementation. Do not use it!</p> - -<h2 id="Syntax">Syntax</h2> - -<pre class="syntaxbox">(for (x of iterable) x) -(for (x of iterable) if (condition) x) -(for (x of iterable) for (y of iterable) x + y) -</pre> - -<h2 id="Description">Description</h2> - -<p>Inside generator comprehensions, these two kinds of components are allowed:</p> - -<ul> - <li>{{JSxRef("Statements/for...of", "for...of")}} and</li> - <li>{{JSxRef("Statements/if...else", "if")}}</li> -</ul> - -<p>The <code>for-of</code> iteration is always the first component. Multiple <code>for-of</code> iterations or if statements are allowed.</p> - -<p>A significant drawback of {{JSxRef("Operators/Array_comprehensions","array comprehensions","","true")}} is that they cause an entire new array to be constructed in memory. When the input to the comprehension is itself a small array the overhead involved is insignificant — but when the input is a large array or an expensive (or indeed infinite) generator the creation of a new array can be problematic.</p> - -<p>Generators enable lazy computation of sequences, with items calculated on-demand as they are needed. Generator comprehensions are syntactically almost identical to array comprehensions — they use parentheses instead of braces— but instead of building an array they create a generator that can execute lazily. You can think of them as short hand syntax for creating generators.</p> - -<p>Suppose we have an iterator <code>it</code> which iterates over a large sequence of integers. We want to create a new iterator that will iterate over their doubles. An array comprehension would create a full array in memory containing the doubled values:</p> - -<pre class="brush: js">var doubles = [for (i in it) i * 2]; -</pre> - -<p>A generator comprehension on the other hand would create a new iterator which would create doubled values on demand as they were needed:</p> - -<pre class="brush: js">var it2 = (for (i in it) i * 2); -console.log(it2.next()); // The first value from it, doubled -console.log(it2.next()); // The second value from it, doubled -</pre> - -<p>When a generator comprehension is used as the argument to a function, the parentheses used for the function call means that the outer parentheses can be omitted:</p> - -<pre class="brush: js">var result = doSomething(for (i in it) i * 2); -</pre> - -<p>The significant difference between the two examples being that by using the generator comprehension, you would only have to loop over the 'obj' structure once, total, as opposed to once when comprehending the array, and again when iterating through it.</p> - -<h2 id="Examples">Examples</h2> - -<h3 id="Simple_generator_comprehensions">Simple generator comprehensions</h3> - -<pre class="brush:js">(for (i of [1, 2, 3]) i * i ); -// generator function which yields 1, 4, and 9 - -[...(for (i of [1, 2, 3]) i * i )]; -// [1, 4, 9] - -var abc = ['A', 'B', 'C']; -(for (letters of abc) letters.toLowerCase()); -// generator function which yields "a", "b", and "c" -</pre> - -<h3 id="Generator_comprehensions_with_if_statement">Generator comprehensions with if statement</h3> - -<pre class="brush: js">var years = [1954, 1974, 1990, 2006, 2010, 2014]; - -(for (year of years) if (year > 2000) year); -// generator function which yields 2006, 2010, and 2014 - -(for (year of years) if (year > 2000) if (year < 2010) year); -// generator function which yields 2006, the same as below: - -(for (year of years) if (year > 2000 && year < 2010) year); -// generator function which yields 2006 -</pre> - -<h3 id="Generator_comprehensions_compared_to_generator_function">Generator comprehensions compared to generator function</h3> - -<p>An easy way to understand generator comprehension syntax, is to compare it with the generator function.</p> - -<p>Example 1: Simple generator.</p> - -<pre class="brush: js">var numbers = [1, 2, 3]; - -// Generator function -(function*() { - for (let i of numbers) { - yield i * i; - } -})(); - -// Generator comprehension -(for (i of numbers) i * i ); - -// Result: both return a generator which yields [1, 4, 9] -</pre> - -<p>Example 2: Using <code>if</code> in generator.</p> - -<pre class="brush: js">var numbers = [1, 2, 3]; - -// Generator function -(function*() { - for (let i of numbers) { - if (i < 3) { - yield i * 1; - } - } -})(); - -// Generator comprehension -(for (i of numbers) if (i < 3) i); - -// Result: both return a generator which yields [1, 2]</pre> - -<h2 id="Specifications">Specifications</h2> - -<p>Generator comprehensions were initially in the ECMAScript 2015 draft, but got removed in revision 27 (August 2014). Please see older revisions of ES2015 for specification semantics.</p> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - - - -<p>{{Compat("javascript.operators.generator_comprehensions")}}</p> - -<h2 id="Differences_to_the_older_JS1.7JS1.8_comprehensions">Differences to the older JS1.7/JS1.8 comprehensions</h2> - -<div class="blockIndicator warning">JS1.7/JS1.8 comprehensions are removed from Gecko 46 ({{bug(1220564)}}).</div> - -<p><strong>Old comprehensions syntax (do not use anymore!):</strong></p> - -<pre class="brush: js example-bad">(X for (Y in Z)) -(X for each (Y in Z)) -(X for (Y of Z)) -</pre> - -<p>Differences:</p> - -<ul> - <li>ES7 comprehensions create one scope per "for" node instead of the comprehension as a whole. - <ul> - <li>Old: <code>[...(()=>x for (x of [0, 1, 2]))][1]() // 2</code></li> - <li>New: <code>[...(for (x of [0, 1, 2]) ()=>x)][1]() // 1, each iteration creates a fresh binding for x. </code></li> - </ul> - </li> - <li>ES7 comprehensions start with "for" instead of the assignment expression. - <ul> - <li>Old: <code>(i * 2 for (i of numbers))</code></li> - <li>New: <code>(for (i of numbers) i * 2)</code></li> - </ul> - </li> - <li>ES7 comprehensions can have multiple <code>if</code> and <code>for</code> components.</li> - <li>ES7 comprehensions only work with <code>{{JSxRef("Statements/for...of", "for...of")}}</code> and not with <code>{{JSxRef("Statements/for...in", "for...in")}}</code> iterations.</li> -</ul> - -<h2 id="See_also">See also</h2> - -<ul> - <li>{{JSxRef("Statements/for...of", "for...of")}}</li> - <li>{{JSxRef("Operators/Array_comprehensions", "Array comprehensions")}}</li> -</ul> diff --git a/files/ko/web/javascript/reference/operators/배열/index.html b/files/ko/web/javascript/reference/operators/배열/index.html deleted file mode 100644 index 4bdd29b61c..0000000000 --- a/files/ko/web/javascript/reference/operators/배열/index.html +++ /dev/null @@ -1,200 +0,0 @@ ---- -title: 배열 내포 -slug: Web/JavaScript/Reference/Operators/배열 -tags: - - JavaScript - - Non-standard - - Obsolete - - Operator - - Reference -translation_of: Archive/Web/JavaScript/Array_comprehensions ---- -<div>{{jsSidebar("Operators")}}</div> - -<div class="warning"><strong>표준이 아닙니다. 사용하지 않는 것을 권장합니다!</strong><br> -Array comprehensions 문법은 비표준이며 Firefox 58부터는 제거됩니다. 향후 사용할 수 없게 되기 때문에 사용하지 않는것을 고려해보세요.<br> -{{jsxref("Array.prototype.map")}}, {{jsxref("Array.prototype.filter")}}, {{jsxref("Functions/Arrow_functions", "arrow functions", "", 1)}}, and {{jsxref("Operators/Spread_operator", "spread syntax", "", 1)}}.</div> - -<div>{{Obsolete_Header(58)}}</div> - -<p><strong>array comprehension </strong>문법은 기존의 배열을 기반으로 새로운 배열을 신속하게 어셈블 할 수 있는 JavaScript 표현식입니다. 그러나 표준 및 Firefox 구현에서 제거되었습니다. 사용하지 마세요!</p> - -<h2 id="Syntax">Syntax</h2> - -<pre class="syntaxbox">[for (x of iterable) x] -[for (x of iterable) if (condition) x] -[for (x of iterable) for (y of iterable) x + y] -</pre> - -<h2 id="Description">Description</h2> - -<p>배열의 이해로 넘어가서, 다음 두가지의 요소들이 사용가능하다.</p> - -<ul> - <li>{{jsxref("Statements/for...of", "for...of")}} and</li> - <li>{{jsxref("Statements/if...else", "if")}}</li> -</ul> - -<p>for-of 반복문은 항상 첫번째 요소이다. 여러개의 for-of 반복문이나 if 제어문을 사용할 수 있다.</p> - -<p>배열 선언은 ECMAScript 2016에서 이전부터 표준으로 정립되어왔으며, 이는 다른 형태의 데이터(contents)를 이용해서 새로운 배열을 구성할 수 있게 해 준다.</p> - -<p>아래의 선언은 숫자로 이루어진 배열 내 각각의 숫자들을 이용해서 double형의 새로운 배열을 만들어준다.</p> - -<pre class="brush: js">var numbers = [1, 2, 3, 4]; -var doubled = [for (i of numbers) i * 2]; -console.log(doubled); // logs 2,4,6,8 -</pre> - -<p>이것은 {{jsxref("Array.prototype.map", "map()")}} 연산자와 같은 기능을 한다.</p> - -<pre class="brush: js">var doubled = numbers.map(i => i * 2); -</pre> - -<p>배열들은 또한 다양한 표현을 통해 몇몇개의 배열 원소들은 선택할 수 도 있다. 아래의 예제는 바로 홀수만 선택하는 예제이다.</p> - -<pre class="brush: js">var numbers = [1, 2, 3, 21, 22, 30]; -var evens = [for (i of numbers) if (i % 2 === 0) i]; -console.log(evens); // logs 2,22,30 -</pre> - -<p>{{jsxref("Array.prototype.filter", "filter()")}} 또한 같은 목적으로 얼마든지 사용가능하다.</p> - -<pre class="brush: js">var evens = numbers.filter(i => i % 2 === 0); -</pre> - -<p>{{jsxref("Array.prototype.map", "map()")}} 그리고 {{jsxref("Array.prototype.filter", "filter()")}} 스타일과 같은 연산자들은 단한 배열 선언과 결합할 수 있다. 아래는 짝수만 필터링하고, 그 원소들을 2배씩하는 배열들을 만드는 예제이다.</p> - -<pre class="brush: js">var numbers = [1, 2, 3, 21, 22, 30]; -var doubledEvens = [for (i of numbers) if (i % 2 === 0) i * 2]; -console.log(doubledEvens); // logs 4,44,60 -</pre> - -<p>배열에서의 [ ] (꺽쇠괄호) 는 범위의 목적으로 암시적인 괄호를 의미한다. {{jsxref("Statements/let","let")}}를 사용하면서 정의된다면, 예제의 i와 같은 변수들이 사용된다. 이는 배열 밖에서 사용할 수 없음을 나타낸다.</p> - -<p>배열의 원소에 넣어지는 것은 굳이 배열일 필요는 없다 <a href="/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators" title="en-US/docs/JavaScript/Guide/Iterators and Generators">iterators and generators</a> 물론 가능하다.</p> - -<p>심지어 문자열도 배열의 원소로 넣을 수 있다. 필터와 지도 액션과 같은 데에 이용할 수 있다.</p> - -<pre class="brush: js">var str = 'abcdef'; -var consonantsOnlyStr = [for (c of str) if (!(/[aeiouAEIOU]/).test(c)) c].join(''); // 'bcdf' -var interpolatedZeros = [for (c of str) c + '0' ].join(''); // 'a0b0c0d0e0f0' -</pre> - -<p>또한 입력 폼이 유지되지 않으므로, 문자열을 뒤집기 위해 {{jsxref("Array.prototype.join", "join()")}} 를 사용해야 한다.</p> - -<h2 id="Examples">Examples</h2> - -<h3 id="단순_배열">단순 배열</h3> - -<pre class="brush:js">[for (i of [1, 2, 3]) i * i ]; -// [1, 4, 9] - -var abc = ['A', 'B', 'C']; -[for (letters of abc) letters.toLowerCase()]; -// ["a", "b", "c"]</pre> - -<h3 id="if문에서의_배열">if문에서의 배열</h3> - -<pre class="brush: js">var years = [1954, 1974, 1990, 2006, 2010, 2014]; -[for (year of years) if (year > 2000) year]; -// [ 2006, 2010, 2014 ] -[for (year of years) if (year > 2000) if (year < 2010) year]; -// [ 2006], the same as below: -[for (year of years) if (year > 2000 && year < 2010) year]; -// [ 2006] -</pre> - -<h3 id="map과_filter를_비교한_배열">map과 filter를 비교한 배열</h3> - -<p>배열문법을 가장 쉽게 이해하는 방법은, 배열에서 {{jsxref("Array.map", "map")}} 그리고 {{jsxref("Array.filter", "filter")}}메소드를 비교하는 것이다.</p> - -<pre class="brush: js">var numbers = [1, 2, 3]; - -numbers.map(function (i) { return i * i }); -numbers.map(i => i * i); -[for (i of numbers) i * i]; -// all are [1, 4, 9] - -numbers.filter(function (i) { return i < 3 }); -numbers.filter(i => i < 3); -[for (i of numbers) if (i < 3) i]; -// all are [1, 2] -</pre> - -<h3 id="2개의_배열">2개의 배열</h3> - -<p>2개의 배열과 2개의 for-of 반복문을 살펴본다.</p> - -<pre class="brush: js">var numbers = [1, 2, 3]; -var letters = ['a', 'b', 'c']; - -var cross = [for (i of numbers) for (j of letters) i + j]; -// ["1a", "1b", "1c", "2a", "2b", "2c", "3a", "3b", "3c"] - -var grid = [for (i of numbers) [for (j of letters) i + j]]; -// [ -// ["1a", "1b", "1c"], -// ["2a", "2b", "2c"], -// ["3a", "3b", "3c"] -// ] - -[for (i of numbers) if (i > 1) for (j of letters) if(j > 'a') i + j] -// ["2b", "2c", "3b", "3c"], the same as below: - -[for (i of numbers) for (j of letters) if (i > 1) if(j > 'a') i + j] -// ["2b", "2c", "3b", "3c"] - -[for (i of numbers) if (i > 1) [for (j of letters) if(j > 'a') i + j]] -// [["2b", "2c"], ["3b", "3c"]], not the same as below: - -[for (i of numbers) [for (j of letters) if (i > 1) if(j > 'a') i + j]] -// [[], ["2b", "2c"], ["3b", "3c"]] -</pre> - -<h2 id="명세">명세</h2> - -<p>ECMAScript 2015 초안에 있었지만 개정 27(2014년 8월)에서 삭제되었습니다. specification semantics에 대해서는 ES2015의 이전 버전을 참조하세요.</p> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - -<p>{{Compat("javascript.operators.array_comprehensions")}}</p> - -<h2 id="오래된_JS1.7JS1.8_comprehensions과의_차이점들">오래된 JS1.7/JS1.8 comprehensions과의 차이점들</h2> - -<div class="warning">Gecko에서 JS1.7 / JS1.8 comprehensions가 46 버전부터 제거되었습니다. ({{bug(1220564)}}).</div> - -<p><strong>이전에 사용된 문법입니다. (더 이상 사용되지 않음!):</strong></p> - -<pre class="brush: js example-bad">[X for (Y in Z)] -[X for each (Y in Z)] -[X for (Y of Z)] -</pre> - -<p>차이점:</p> - -<ul> - <li>ESNext comprehensions는 전체comprehension 대신 "for"노드마다 하나의 범위를 만듭니다. - <ul> - <li>Old: <code>[()=>x for (x of [0, 1, 2])][1]() // 2</code></li> - <li>New: <code>[for (x of [0, 1, 2]) ()=>x][1]() // 1, each iteration creates a fresh binding for x. </code></li> - </ul> - </li> - <li>ESNext comprehensions은 assignment expression대신 "for"로 시작합니다. - <ul> - <li>Old: <code>[i * 2 for (i of numbers)]</code></li> - <li>New: <code>[for (i of numbers) i * 2]</code></li> - </ul> - </li> - <li>ESNext comprehensions는 <code>if</code> 및 <code>for</code> 구성 요소를 여러 개 가질 수 있습니다.</li> - <li>ESNext comprehensions <code>{{jsxref("Statements/for...of", "for...of")}}</code>에서만 동작하고 <code>{{jsxref("Statements/for...in", "for...in")}}</code>에서는 동작하지 않습니다.</li> -</ul> - -<p>버그 업데이트에 대한 제안은 <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1220564#c42">Bug 1220564, comment 42</a>를 참조하세요.</p> - -<h2 id="더보기">더보기</h2> - -<ul> - <li>{{jsxref("Statements/for...of", "for...of")}}</li> - <li>{{jsxref("Operators/Generator_comprehensions", "Generator comprehensions", "" ,1)}}</li> -</ul> diff --git a/files/ko/web/javascript/reference/statements/for_each...in/index.html b/files/ko/web/javascript/reference/statements/for_each...in/index.html deleted file mode 100644 index 9fa9901aae..0000000000 --- a/files/ko/web/javascript/reference/statements/for_each...in/index.html +++ /dev/null @@ -1,85 +0,0 @@ ---- -title: for each...in -slug: Web/JavaScript/Reference/Statements/for_each...in -tags: - - Deprecated - - E4X - - JavaScript - - Obsolete - - Statement -translation_of: Archive/Web/JavaScript/for_each...in ---- -<div>{{jsSidebar("Statements")}}</div> - -<div class="warning"> -<p>The <code>for each...in</code> statement is deprecated as the part of ECMA-357 (<a href="/en-US/docs/Archive/Web/E4X" title="/en-US/docs/E4X">E4X</a>) standard. E4X support has been removed. Consider using <a href="/en-US/docs/Web/JavaScript/Reference/Statements/for...of">for...of</a> instead.<br> - <br> - <strong>Firefox now warns about the usage of <code>for each...in</code> and it no longer works starting with Firefox 57.<br> - Please see <a href="/en-US/docs/Web/JavaScript/Reference/Errors/For-each-in_loops_are_deprecated">Warning: JavaScript 1.6's for-each-in loops are deprecated</a> for migration help.</strong></p> -</div> - -<p><code><strong>for each...in</strong></code> 문은 객체의 모든 속성 값에 대해 지정된 변수를 반복합니다. 각각의 고유한 특성에 대해 지정된 명령문이 실행됩니다.</p> - -<h2 id="Syntax">Syntax</h2> - -<pre class="syntaxbox">for each (<em>variable</em> in <em>object</em>) { - <em>statement</em> -}</pre> - -<dl> - <dt><code>variable</code></dt> - <dd>var 키워드로 선택적으로 선언된 속성 값을 반복하는 변수입니다. 이 변수는 루프가 아니라 함수의 local이 됩니다.</dd> -</dl> - -<dl> - <dt><code>object</code></dt> - <dd>반복될 객체입니다.</dd> -</dl> - -<dl> - <dt><code>statement</code></dt> - <dd>각 속성에 대해 실행할 명령문입니다. 루프 내에서 여러 명령문을 실행하려면 블록 명령문 ({...})을 사용하여 해당 명령문을 그룹화하십시오.</dd> -</dl> - -<h2 id="Description">Description</h2> - -<p>일부 기본 제공 속성은 반복되지 않습니다. 여기에는 객체 기본 제공 메서드 전부가 포함됩니다.</p> - -<p>ex) String의 indexOf 메소드.</p> - -<p>그러나 사용자가 정의한 모든 속성은 반복됩니다.</p> - -<h2 id="Examples">Examples</h2> - -<h3 id="Using_for_each...in">Using <code>for each...in</code></h3> - -<p><strong>Warning:</strong> Never use a loop like this on arrays. Only use it on objects. See <a href="/en-US/docs/Web/JavaScript/Reference/Statements/for...in"><code>for...in</code></a> for more details.</p> - -<p>The following snippet iterates over an object's properties, calculating their sum:</p> - -<pre class="brush:js">var sum = 0; -var obj = {prop1: 5, prop2: 13, prop3: 8}; - -for each (var item in obj) { - sum += item; -} - -console.log(sum); // logs "26", which is 5+13+8</pre> - -<h2 id="Specifications">Specifications</h2> - -<p>Not part of a current ECMA-262 specification. Implemented in JavaScript 1.6 and deprecated.</p> - -<h2 id="Browser_compatibility">Browser compatibility</h2> - - - -<p>{{Compat("javascript.statements.for_each_in")}}</p> - -<h2 id="See_also">See also</h2> - -<ul> - <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/for...in">for...in</a></code> - a similar statement that iterates over the property <em>names</em>.</li> - <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/for...of">for...of</a></code> - a similar statement that iterates over the property <em>values</em> but can only be used for iteratable types, so not for generic objects</li> - <li><code><a href="/en-US/docs/JavaScript/Reference/Statements/for">for</a></code></li> -</ul> |