aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/javascript/reference/functions
diff options
context:
space:
mode:
Diffstat (limited to 'files/uk/web/javascript/reference/functions')
-rw-r--r--files/uk/web/javascript/reference/functions/arguments/@@iterator/index.html77
-rw-r--r--files/uk/web/javascript/reference/functions/arguments/index.html282
-rw-r--r--files/uk/web/javascript/reference/functions/arguments/length/index.html85
-rw-r--r--files/uk/web/javascript/reference/functions/arrow_functions/index.html363
-rw-r--r--files/uk/web/javascript/reference/functions/get/index.html175
-rw-r--r--files/uk/web/javascript/reference/functions/index.html605
-rw-r--r--files/uk/web/javascript/reference/functions/method_definitions/index.html219
-rw-r--r--files/uk/web/javascript/reference/functions/rest_parameters/index.html212
-rw-r--r--files/uk/web/javascript/reference/functions/set/index.html152
9 files changed, 0 insertions, 2170 deletions
diff --git a/files/uk/web/javascript/reference/functions/arguments/@@iterator/index.html b/files/uk/web/javascript/reference/functions/arguments/@@iterator/index.html
deleted file mode 100644
index 247d90c724..0000000000
--- a/files/uk/web/javascript/reference/functions/arguments/@@iterator/index.html
+++ /dev/null
@@ -1,77 +0,0 @@
----
-title: 'arguments[@@iterator]()'
-slug: Web/JavaScript/Reference/Functions/arguments/@@iterator
-tags:
- - JavaScript
- - arguments
- - Властивість
- - функції
-translation_of: Web/JavaScript/Reference/Functions/arguments/@@iterator
----
-<div>{{jsSidebar("Functions")}}</div>
-
-<p>Початковим значенням властивості <code><strong>@@iterator</strong></code> є та сама функція, що є початковим значенням властивості {{jsxref("Array.prototype.values")}}.</p>
-
-<h2 id="Синтаксис">Синтаксис</h2>
-
-<pre class="syntaxbox"><var>arguments</var>[Symbol.iterator]()</pre>
-
-<h2 id="Приклади">Приклади</h2>
-
-<h3 id="Перебір_за_допомогою_циклу_for...of">Перебір за допомогою циклу <code>for...of</code></h3>
-
-<pre class="brush: js">function f() {
- // ваш переглядач має підтримувати цикл for..of
- // та оголошення змінних у циклах for через let
- for (let letter of arguments) {
- console.log(letter);
- }
-}
-f('w', 'y', 'k', 'o', 'p');
-</pre>
-
-<h2 id="Специфікації">Специфікації</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Специфікація</th>
- <th scope="col">Статус</th>
- <th scope="col">Коментар</th>
- </tr>
- <tr>
- <td>{{SpecName('ES6', '#sec-createunmappedargumentsobject', ' CreateUnmappedArgumentsObject')}}</td>
- <td>{{Spec2('ES6')}}</td>
- <td>Початкове визначення.</td>
- </tr>
- <tr>
- <td>{{SpecName('ES6', '#sec-createmappedargumentsobject', ' CreateMappedArgumentsObject')}}</td>
- <td>{{Spec2('ES6')}}</td>
- <td>Початкове визначення.</td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-createunmappedargumentsobject', 'CreateUnmappedArgumentsObject')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-createmappedargumentsobject', 'CreateMappedArgumentsObject')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td></td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Сумісність_з_веб-переглядачами">Сумісність з веб-переглядачами</h2>
-
-<div>
-
-
-<p>{{Compat("javascript.functions.arguments.@@iterator")}}</p>
-</div>
-
-<h2 id="Див._також">Див. також</h2>
-
-<ul>
- <li>{{jsxref("Array.prototype.values()")}}</li>
-</ul>
diff --git a/files/uk/web/javascript/reference/functions/arguments/index.html b/files/uk/web/javascript/reference/functions/arguments/index.html
deleted file mode 100644
index 90a2963025..0000000000
--- a/files/uk/web/javascript/reference/functions/arguments/index.html
+++ /dev/null
@@ -1,282 +0,0 @@
----
-title: Об'єкт arguments
-slug: Web/JavaScript/Reference/Functions/arguments
-tags:
- - JavaScript
- - аргументи
- - методи
- - функції
-translation_of: Web/JavaScript/Reference/Functions/arguments
----
-<div>
-<div>{{jsSidebar("Functions")}}</div>
-</div>
-
-<p>Подібний до масиву об'єкт <strong><code>arguments</code></strong> описує аргументи, які було передано у функцію.</p>
-
-<h2 id="Синтаксис">Синтаксис</h2>
-
-<pre class="syntaxbox">arguments
-</pre>
-
-<h2 id="Опис">Опис</h2>
-
-<p>Об'єкт <code>arguments</code> — це локальна змінна, яка доступна всередині кожної функції. Цей об'єкт містить інформацію про кількість та значення всіх параметрів, що їх було передано до функції під час її виклику. Для читання чи змінювання значень аргументів можна скористатися синтаксисом доступу до елементів масиву, де індекс першого переданого аргументу починається з <code>0</code>.</p>
-
-<p>Для прикладу, якщо в функцію передано три аргументи, звернутися до них можна так:</p>
-
-<pre class="brush: js">arguments[0]
-arguments[1]
-arguments[2]
-</pre>
-
-<p>Значення можна не лише читати, а й змінювати таким чином:</p>
-
-<pre class="brush: js">arguments[1] = 'new value';
-</pre>
-
-<p>Об'єкт <code>arguments</code> не є {{jsxref("Array", "масивом")}}. Він подібний до масиву, але не має жодних властивостей масиву, крім <a href="/uk/docs/Web/JavaScript/Reference/Functions/arguments/length">length</a> (довжини). Наприклад, він не має методу <a href="/uk/docs/Web/JavaScript/Reference/Global_Objects/Array/pop">pop</a>. Проте його можна перетворити на справжній масив:</p>
-
-<pre class="brush: js">var args = Array.prototype.slice.call(arguments);
-var args = [].slice.call(arguments);
-</pre>
-
-<p>Також можна скористатися методом {{jsxref("Array.from()")}} або <a href="/uk/docs/Web/JavaScript/Reference/Operators/Оператор_розпакування">оператором розпакування</a>, щоб перетворити arguments на справжній масив:</p>
-
-<pre class="brush: js">var args = Array.from(arguments);
-
-// ES2015
-var args = [...arguments];
-</pre>
-
-<div class="warning">
-<p>Застосування методу <code>slice</code> до <code>arguments</code> заважає оптимізації в деяких рушіях JavaScript (<a href="https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments">наприклад, V8</a>). Отже, якщо вас це обходить, створюйте новий масив шляхом перебору елементів псевдомасиву arguments. Можна також скористатися конструктором <code>Array</code> як функцією:</p>
-
-<pre class="brush: js">var args = (arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments));
-</pre>
-</div>
-
-<p>Об'єкт <code>arguments</code> корисний в тих випадках, коли кількість аргументів функції заздалегідь невідома. Існує чимало прикладів того, коли функцію можна викликати із різною множиною аргументів, реалізуючи таким чином поведінку на кшталт «перевантаження», яке в чистому вигляді відсутнє в JavaScript. Очевидно, що така «перевантажена» функція не завше може задовольнитися переліком формальних аргументів однієї <a href="/uk/docs/Glossary/Signature/Function">сигнатури</a>. Саме тут arguments може стати в нагоді.</p>
-
-<p>Завважте, що властивість <a href="/uk/docs/Web/JavaScript/Reference/Functions/arguments/length">arguments.length</a> — це кількість фактичних (а не формальних) аргументів, які дійсно було передано до функції. Натомість для визначення кількості формальних параметрів, оголошених сигнатурою функції, скористайтесь властивістю <a href="/uk/docs/Web/JavaScript/Reference/Global_Objects/Function/length">Function.length</a>.</p>
-
-<p>Як свідчить <code>typeof</code>, <code>arguments</code> є об'єктом:</p>
-
-<pre class="brush: js">console.log(typeof arguments); // 'object'</pre>
-
-<p>Тип кожного окремого аргументу можна визначити за допомогою typeof та індексації псевдомасиву <code>arguments</code>:</p>
-
-<pre class="brush: js">console.log(typeof arguments[0]); // значення typeof конкретного аргументу</pre>
-
-<h2 id="Властивості">Властивості</h2>
-
-<dl>
- <dt><code><a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments/callee">arguments.callee</a></code></dt>
- <dd>Посилання на функцію, що саме виконується.</dd>
- <dt><code><a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments/caller">arguments.caller</a></code> {{ Obsolete_inline() }}</dt>
- <dd>Посилання на функцію, з якої здійснили виклик поточної (яка саме виконується).</dd>
- <dt><code><a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments/length">arguments.length</a></code></dt>
- <dd>Кількість аргументів, що було фактично передано до функції.</dd>
- <dt><code><a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments/@@iterator">arguments[@@iterator]</a></code></dt>
- <dd>Вертає новий ітератор масиву, що містить значення за кожним індексом в <code>arguments</code>.</dd>
-</dl>
-
-<h2 id="Приклади">Приклади</h2>
-
-<h3 id="Функція_що_з'єднує_кілька_рядків">Функція, що з'єднує кілька рядків</h3>
-
-<p>В цьому прикладі наведно функцію, яка з'єднує кілька рядків в один. Єдиний формальний аргумент функції — це рядок, що виступатиме розділовою послідовністю символів між складовими, що підлягають з'єднуванню. Це можна втілити наступним чином:</p>
-
-<pre class="brush:js">function myJoin(separator) {
- var args = Array.prototype.slice.call(arguments, 1);
- return args.join(separator);
-}</pre>
-
-<p>Отже, можна передавати довільну кількість аргументів, послідовність яких (окрім першого, що виступає розділовою послідовністю символів) перетворюється на масив, а тоді з'єднується за допомогою {{jsxref("Array.join()")}}.</p>
-
-<p>Отож маємо:</p>
-
-<pre class="brush:js">// вертає "камінь, ножиці, папір"
-myJoin(", ", "камінь", "ножиці", "папір");
-
-// вертає "я; дух; одвічна стихія; потопа"
-myJoin("; ", "я", "дух", "одвічна стихія", "потопа");
-
-// вертає "Чому Пінгвіни Живуть Зимою Без Своїх Фантазій"
-myJoin(" ", "Чому", "Пінгвіни", "Живуть", "Зимою", "Без", "Своїх", "Фантазій");</pre>
-
-<h3 id="Функція_що_створює_HTML-списки">Функція, що створює HTML-списки</h3>
-
-<p>В наступному прикладі наведено функцію, що створює HTML-розмітку списку. Єдиний формальний аргумент функції — текстовий рядок, що визначає різновид списку ("o" для впорядкованого списку, чи то пак — нумерованого, — або "u" для невпорядкованого). Решта аргументів, визначатиме власне елементи списку. Одна з можливих реалізацій виглядає наступним чином:</p>
-
-<pre class="brush:js">function list(type) {
-  var markup = "&lt;" + type + "l&gt;";
-
-  for (var i = 1; i &lt; arguments.length; i++) {
-  markup += "&lt;li&gt;" + arguments[i] + "&lt;/li&gt;";
-  }
-  markup += "&lt;/" + type + "l&gt;";
-
- return markup
-}</pre>
-
-<p>До функції можна передати будь-яку кількість аргументів, створивши список з довільною кількістю елементів. Наприклад, так:</p>
-
-<pre class="brush:js">var markup = list("u", "Крижина", "Стежина", "Чужина");
-
-console.log(markup); // виводить "&lt;ul&gt;&lt;li&gt;Крижина&lt;/li&gt;&lt;li&gt;Стежина&lt;/li&gt;&lt;li&gt;Чужина&lt;/li&gt;&lt;ul&gt;"
-</pre>
-
-<h3 id="Решта_типові_та_деструктуризовані_параметри">Решта, типові та деструктуризовані параметри</h3>
-
-<p>Об'єкт <code>arguments</code> можна використовувати в поєднанні з <a href="/uk/docs/Web/JavaScript/Reference/Functions/решта_параметрів">рештою</a>, <a href="/uk/docs/Web/JavaScript/Reference/Functions/Default_parameters">типовими</a> та <a href="/uk/docs/Web/JavaScript/Reference/Operators/Деструктуризація">деструктуризованими</a> параметрами.</p>
-
-<pre class="brush: js">function foo(...args) {
- return arguments;
-}
-
-foo(1, 2, 3); // вертає {"0": 1, "1": 2, "2": 3}
-</pre>
-
-<p>І хоча присутність <em>решти</em>, <em>типових</em> чи <em>деструктуризованих</em> параметрів не змінює поведінки об'єкта <a href="/uk/docs/Web/JavaScript/Reference/Strict_mode#Спрощення_eval_та_arguments">arguments в суворому режимі</a>, в звичайному режимі все ж є невеличка різниця. За відсутності <em>решти</em>, <em>типових</em> чи <em>деструктуризованих</em> параметрів функція, яка виконується в звичайному (не в суворому) режимі, передбачає збереження зв'язку між значеннями формальних параметрів та значеннями, що їх містить об'єкт <code>arguments</code>:</p>
-
-<pre class="brush: js">function foo(a) {
- arguments[0] = 99; // змінюючи arguments[0] ми також змінюємо a
- console.log(a);
-}
-
-foo(10); // 99</pre>
-
-<p>І навпаки:</p>
-
-<pre class="brush: js">function foo(a) {
- a = 99; // змінюючи a ми також змінюємо arguments[0]
- console.log(arguments[0]);
-}
-
-foo(10); // 99</pre>
-
-<p>Натомість, наявність таких (<em>решти</em>, <em>типових</em> чи <em>деструктуризованих</em>) параметрів той зв'язок порушує:</p>
-
-<pre class="brush: js">function foo(a = 55) {
- arguments[0] = 99; // змінюючи arguments[0] ми більше не впливаємо на a
- console.log(a);
-}
-
-foo(10); // 10</pre>
-
-<p>І навпаки:</p>
-
-<pre class="brush: js">function foo(a = 55) {
- a = 99; // змінюючи a ми більше не впливаємо на arguments[0]
- console.log(arguments[0]);
-}
-
-foo(10); // 10</pre>
-
-<p>Ба більше:</p>
-
-<pre class="brush: js">function foo(a = 55) {
- console.log(arguments[0]);
-}
-
-foo(); // undefined</pre>
-
-<p>Ясна річ, цей зв'язок поширюється лише на значення змінних, а не на вміст об'єктів:</p>
-
-<pre class="brush: js">function foo(object = {}) {
-  object.value = 222;
-  console.debug(arguments[0].value);
-}
-
-foo({value: 111}); // Object {value: 222}</pre>
-
-<h2 id="Специфікації">Специфікації</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Специфікація</th>
- <th scope="col">Статус</th>
- <th scope="col">Коментар</th>
- </tr>
- <tr>
- <td>{{SpecName('ES1')}}</td>
- <td>{{Spec2('ES1')}}</td>
- <td>Первинне визначення. Реалізовано у JavaScript 1.1</td>
- </tr>
- <tr>
- <td>{{SpecName('ES5.1', '#sec-10.6', 'Arguments Object')}}</td>
- <td>{{Spec2('ES5.1')}}</td>
- <td> </td>
- </tr>
- <tr>
- <td>{{SpecName('ES6', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}</td>
- <td>{{Spec2('ES6')}}</td>
- <td> </td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td> </td>
- </tr>
- </tbody>
-</table>
-
-<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>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</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>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- </tr>
- </tbody>
-</table>
-</div>
-
-<h2 id="Див._також">Див. також</h2>
-
-<ul>
- <li>{{jsxref("Function")}}</li>
-</ul>
diff --git a/files/uk/web/javascript/reference/functions/arguments/length/index.html b/files/uk/web/javascript/reference/functions/arguments/length/index.html
deleted file mode 100644
index 77246c5b4e..0000000000
--- a/files/uk/web/javascript/reference/functions/arguments/length/index.html
+++ /dev/null
@@ -1,85 +0,0 @@
----
-title: arguments.length
-slug: Web/JavaScript/Reference/Functions/arguments/length
-tags:
- - JavaScript
- - arguments
- - Властивість
- - функції
-translation_of: Web/JavaScript/Reference/Functions/arguments/length
----
-<div>{{jsSidebar("Functions")}}</div>
-
-<p>Властивість <strong><code>arguments.length</code></strong> містить кількість аргументів, переданих у функцію.</p>
-
-<h2 id="Синтаксис">Синтаксис</h2>
-
-<pre class="syntaxbox">arguments.length</pre>
-
-<h2 id="Опис">Опис</h2>
-
-<p>Властивість <code>arguments.length</code> надає кількість аргументів, які фактично передані у функцію. Вона може бути більшою або меншою, ніж визначена кількість параметрів (дивіться {{jsxref("Function.length")}}).</p>
-
-<h2 id="Приклади">Приклади</h2>
-
-<h3 id="Використання_arguments.length">Використання <code>arguments.length</code></h3>
-
-<p>В цьому прикладі ми визначаємо функцію, яка рахує суму двох або більше аргументів.</p>
-
-<pre class="brush: js">function adder(base /*, n2, ... */) {
- base = Number(base);
- for (var i = 1; i &lt; arguments.length; i++) {
- base += Number(arguments[i]);
- }
- return base;
-}
-</pre>
-
-<div class="note">
-<p>Зауважте різницю між {{jsxref("Function.length")}} та arguments.length</p>
-</div>
-
-<h2 id="Специфікації">Специфікації</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Специфікація</th>
- <th scope="col">Статус</th>
- <th scope="col">Коментар</th>
- </tr>
- <tr>
- <td>{{SpecName('ES1')}}</td>
- <td>{{Spec2('ES1')}}</td>
- <td>Початкове визначення. Реалізоване у JavaScript 1.1</td>
- </tr>
- <tr>
- <td>{{SpecName('ES5.1', '#sec-10.6', 'Arguments Object')}}</td>
- <td>{{Spec2('ES5.1')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('ES6', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}</td>
- <td>{{Spec2('ES6')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td></td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Сумісність_з_веб-переглядачами">Сумісність з веб-переглядачами</h2>
-
-
-
-<p>{{Compat("javascript.functions.arguments.length")}}</p>
-
-<h2 id="Див._також">Див. також</h2>
-
-<ul>
- <li>{{jsxref("Function")}}</li>
- <li>{{jsxref("Function.length")}}</li>
-</ul>
diff --git a/files/uk/web/javascript/reference/functions/arrow_functions/index.html b/files/uk/web/javascript/reference/functions/arrow_functions/index.html
deleted file mode 100644
index 90e1c4c6a3..0000000000
--- a/files/uk/web/javascript/reference/functions/arrow_functions/index.html
+++ /dev/null
@@ -1,363 +0,0 @@
----
-title: Стрілкові функції
-slug: Web/JavaScript/Reference/Functions/Arrow_functions
-translation_of: Web/JavaScript/Reference/Functions/Arrow_functions
-original_slug: Web/JavaScript/Reference/Functions/Стрілкові_функції
----
-<div>{{jsSidebar("Functions")}}</div>
-
-<p><strong>Вирази стрілкових функцій </strong>мають більш короткий синтаксис, аніж <a href="/en-US/docs/Web/JavaScript/Reference/Operators/function">функціональні вирази</a> і не мають свого власного <code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/this">this</a></code>, <a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments">arguments</a>, <a href="/en-US/docs/Web/JavaScript/Reference/Operators/super">super</a>, і <a href="/en-US/docs/Web/JavaScript/Reference/Operators/new.target">new.target</a>. Вони не можуть бути використані як конструктор і завжди анонімні.</p>
-
-<h2 id="Синтаксис">Синтаксис</h2>
-
-<h3 id="Basic_Syntax">Basic Syntax</h3>
-
-<pre class="syntaxbox"><strong>(<em></em></strong><em>параметр1</em><strong><em></em></strong>,<em>параметр2</em>, …, <em>параметрN</em><strong>) =&gt; {</strong> <em>оператори</em> <strong>}</strong>
-<strong>(</strong><em>параметр1</em>, <em>параметр2</em>, …, <em>параметрN</em><strong>) =&gt;</strong> <em>вираз</em>
-// еквівалентно до запису: <strong>(</strong><em>параметр1</em>,<em>параметр2</em>, …, <em>параметрN</em><strong>)</strong> =&gt; { return <em>вираз</em>; }
-
-// Якщо у функції тільки один параметр, то дужки не обов'язкові:
-<em>(параметр)</em> <strong>=&gt; {</strong> <em>оператори</em> <strong>}</strong>
-<em>параметр</em> <strong>=&gt;</strong> { <em>оператори </em>}
-<em>параметр</em> <strong>=&gt;</strong> <em>вираз</em>
-
-
-// Список параметрів для функції без параметрів повинен бути записаний у парі фігурних дужок.
-() =&gt; { <em>оператори</em> }
-</pre>
-
-<h3 id="Advanced_Syntax">Advanced Syntax</h3>
-
-<pre class="syntaxbox">// Візьміть тіло функції у дужки, якщо вона повертає об'єкт
-<em>params</em> =&gt; ({<em>foo: bar</em>})
-
-// Залишкові параметри та параметри за замовчуванням підтримуються як і в звичайних функціях
-(<em>параметр1</em>, <em>параметр2</em>, <strong>...залишкові параметри</strong>) =&gt; { <em>оператори</em> }
-(<em>параметр1</em> <strong>= значення_за_замовчуванням</strong>, <em>параметр2</em>, …, параметрN <strong>= значення_за_замовчуваннямN</strong>) =&gt; { <em>оператори</em> }
-
-// Деструктиризація в списку параметрів також підтримується:
-let f = ([a, b] = [1, 2], {x: c} = {x: a + b}) =&gt; a + b + c;
-f();
-// 6
-</pre>
-
-<h2 id="Опис">Опис</h2>
-
-<p>Див. також <a href="https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/">"ES6 In Depth: Arrow functions" on hacks.mozilla.org</a>.</p>
-
-<p>Появу стрілкових функцій зумовили два фактори: можливість більш короткого запису і випадки, коли сутність <code>this</code> не обов'язкова.</p>
-
-<h3 id="Коротший_запис">Коротший запис</h3>
-
-<pre class="brush: js">var materials = [
- 'Hydrogen',
- 'Helium',
- 'Lithium',
- 'Beryllium'
-];
-
-materials.<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map">map</a>(function(material) {
- return material.length;
-}); // [8, 6, 7, 9]
-
-materials.<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map">map</a>((material) =&gt; {
- return material.length;
-}); // [8, 6, 7, 9]
-
-materials.<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map">map</a>(material =&gt; material.length); // [8, 6, 7, 9]
-</pre>
-
-<h3 id="Спільний_this">Спільний <code>this</code></h3>
-
-<p>До появи стрілкових функцій кожна нова функція мала власне значення <code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/this">this</a></code> :</p>
-
-<ul>
- <li>новий об'єкт у випадку конструктора</li>
- <li>undefined для викликів функції в <a href="/en-US/docs/Web/JavaScript/Reference/Strict_mode">strict mode</a></li>
- <li>контекст об'єкту при виклику функції як методу об'єкту</li>
- <li>і т. ін.</li>
-</ul>
-
-<p>Це все було далеким від ідеалів об'єктно-орієнтованого програмування.</p>
-
-<pre class="brush: js">function Person() {
- // The Person() constructor defines `this` as an instance of itself.
- this.age = 0;
-
- setInterval(function growUp() {
- // In non-strict mode, the growUp() function defines `this`
- // as the global object, which is different from the `this`
- // defined by the Person() constructor.
- this.age++;
- }, 1000);
-}
-
-var p = new Person();</pre>
-
-<p>В ECMAScript 3/5 ця проблема вирішувалась шляхом присвоєння значення <code>this</code> змінній, оголошеній всередині функції.</p>
-
-<pre class="brush: js">function Person() {
- var that = this;
- that.age = 0;
-
- setInterval(function growUp() {
- // The callback refers to the `that` variable of which
- // the value is the expected object.
- that.age++;
- }, 1000);
-}</pre>
-
-<p>Або можна створити <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind">bound function</a> (прив'язану функцію), в яку передати значення <code>this</code> для функції (функція <code>growUp()</code> в прикладі вище).</p>
-
-<p>Стрілкова функція не має власного контексту <code>this</code>, а використовує <code>this</code> з контексту вище. Тому в коді, наведеному нижче, <code>this</code> для функції <code>setInterval</code> має таке ж значення, як і <code>this</code> зовнішньої функції:</p>
-
-<pre class="brush: js">function Person(){
- this.age = 0;
-
- setInterval(() =&gt; {
- this.age++; // |this| properly refers to the person object
- }, 1000);
-}
-
-var p = new Person();</pre>
-
-<h4 id="Relation_with_strict_mode">Relation with strict mode</h4>
-
-<p>Given that <code>this</code> comes from the surrounding lexical context, <a href="/en-US/docs/Web/JavaScript/Reference/Strict_mode">strict mode</a> rules with regard to <code>this</code> are ignored.</p>
-
-<pre class="brush: js">var f = () =&gt; { 'use strict'; return this; };
-f() === window; // or the global object</pre>
-
-<p>All other strict mode rules apply normally.</p>
-
-<h4 id="Invoked_through_call_or_apply">Invoked through call or apply</h4>
-
-<p>Since arrow functions do not have their own <code>this</code>, the methods <code>call()</code> or <code>apply()</code> can only pass in parameters. <code>thisArg</code> is ignored.</p>
-
-<pre class="brush: js">var adder = {
- base: 1,
-
- add: function(a) {
- var f = v =&gt; v + this.base;
- return f(a);
- },
-
- addThruCall: function(a) {
- var f = v =&gt; v + this.base;
- var b = {
- base: 2
- };
-
- return f.call(b, a);
- }
-};
-
-console.log(adder.add(1)); // This would log to 2
-console.log(adder.addThruCall(1)); // This would log to 2 still</pre>
-
-<h3 id="No_binding_of_arguments">No binding of <code>arguments</code></h3>
-
-<p>Arrow functions do not have their own <a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments"><code>arguments</code> object</a>. Thus, in this example, <code>arguments</code> is simply a reference to the arguments of the enclosing scope:</p>
-
-<pre class="brush: js">var arguments = [1, 2, 3];
-var arr = () =&gt; arguments[0];
-
-arr(); // 1
-
-function foo(n) {
- var f = () =&gt; arguments[0] + n; // <em>foo</em>'s implicit arguments binding. arguments[0] is n
- return f(10);
-}
-
-foo(1); // 2</pre>
-
-<p>In most cases, using <a href="/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters">rest parameters</a> is a good alternative to using an <code>arguments</code> object.</p>
-
-<pre class="brush: js">function foo(n) {
- var f = (...args) =&gt; args[0] + n;
- return f(10);
-}
-
-foo(1); // 11</pre>
-
-<h3 id="Arrow_functions_used_as_methods">Arrow functions used as methods</h3>
-
-<p>As stated previously, arrow function expressions are best suited for non-method functions. Let's see what happens when we try to use them as methods:</p>
-
-<pre class="brush: js">'use strict';
-var obj = {
- i: 10,
- b: () =&gt; console.log(this.i, this),
- c: function() {
- console.log(this.i, this);
- }
-}
-obj.b(); // prints undefined, Window {...} (or the global object)
-obj.c(); // prints 10, Object {...}</pre>
-
-<p>Arrow functions do not have their own <code>this</code>. Another example involving {{jsxref("Object.defineProperty()")}}:</p>
-
-<pre class="brush: js">'use strict';
-var obj = {
- a: 10
-};
-
-Object.defineProperty(obj, 'b', {
- get: () =&gt; {
- console.log(this.a, typeof this.a, this);
- return this.a + 10; // represents global object 'Window', therefore 'this.a' returns 'undefined'
- }
-});
-</pre>
-
-<h3 id="Use_of_the_new_operator">Use of the <code>new</code> operator</h3>
-
-<p>Arrow functions cannot be used as constructors and will throw an error when used with <code>new</code>.</p>
-
-<pre class="brush: js">var Foo = () =&gt; {};
-var foo = new Foo(); // TypeError: Foo is not a constructor</pre>
-
-<h3 id="Use_of_prototype_property">Use of <code>prototype</code> property</h3>
-
-<p>Arrow functions do not have a <code>prototype</code> property.</p>
-
-<pre class="brush: js">var Foo = () =&gt; {};
-console.log(Foo.prototype); // undefined
-</pre>
-
-<h3 id="Use_of_the_yield_keyword">Use of the <code>yield</code> keyword</h3>
-
-<p>The <code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/yield">yield</a></code> keyword may not be used in an arrow function's body (except when permitted within functions further nested within it). As a consequence, arrow functions cannot be used as generators.</p>
-
-<h2 id="Тіло_функції">Тіло функції</h2>
-
-<p>Arrow functions can have either a "concise body" or the usual "block body".</p>
-
-<p>In a concise body, only an expression is specified, which becomes the explicit return value. In a block body, you must use an explicit <code>return</code> statement.</p>
-
-<pre class="brush: js">var func = x =&gt; x * x;
-// concise body syntax, implied "return"
-
-var func = (x, y) =&gt; { return x + y; };
-// with block body, explicit "return" needed
-</pre>
-
-<h2 id="Повернення_літерала_обєкта">Повернення літерала об'єкта</h2>
-
-<p>Keep in mind that returning object literals using the concise body syntax <code>params =&gt; {object:literal}</code> will not work as expected.</p>
-
-<pre class="brush: js">var func = () =&gt; { foo: 1 };
-// Calling func() returns undefined!
-
-var func = () =&gt; { foo: function() {} };
-// SyntaxError: function statement requires a name</pre>
-
-<p>This is because the code inside braces ({}) is parsed as a sequence of statements (i.e. <code>foo</code> is treated like a label, not a key in an object literal).</p>
-
-<p>Remember to wrap the object literal in parentheses.</p>
-
-<pre class="brush: js">var func = () =&gt; ({foo: 1});</pre>
-
-<h2 id="Розрив_рядка">Розрив рядка</h2>
-
-<p>An arrow function cannot contain a line break between its parameters and its arrow.</p>
-
-<pre class="brush: js">var func = ()
- =&gt; 1;
-// SyntaxError: expected expression, got '=&gt;'</pre>
-
-<h2 id="Порядок_розбору">Порядок розбору</h2>
-
-<p>Although the arrow in an arrow function is not an operator, arrow functions have special parsing rules that interact differently with <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence">operator precedence</a> compared to regular functions.</p>
-
-<pre class="brush: js">let callback;
-
-callback = callback || function() {}; // ok
-
-callback = callback || () =&gt; {};
-// SyntaxError: invalid arrow-function arguments
-
-callback = callback || (() =&gt; {}); // ok
-</pre>
-
-<h2 id="Ще_приклади">Ще приклади</h2>
-
-<pre class="brush: js">// An empty arrow function returns undefined
-let empty = () =&gt; {};
-
-(() =&gt; 'foobar')();
-// Returns "foobar"
-// (this is an Immediately Invoked Function Expression
-// see 'IIFE' in glossary)
-
-var simple = a =&gt; a &gt; 15 ? 15 : a;
-simple(16); // 15
-simple(10); // 10
-
-let max = (a, b) =&gt; a &gt; b ? a : b;
-
-// Easy array filtering, mapping, ...
-
-var arr = [5, 6, 13, 0, 1, 18, 23];
-
-var sum = arr.reduce((a, b) =&gt; a + b);
-// 66
-
-var even = arr.filter(v =&gt; v % 2 == 0);
-// [6, 0, 18]
-
-var double = arr.map(v =&gt; v * 2);
-// [10, 12, 26, 0, 2, 36, 46]
-
-// More concise promise chains
-promise.then(a =&gt; {
- // ...
-}).then(b =&gt; {
- // ...
-});
-
-// Parameterless arrow functions that are visually easier to parse
-setTimeout( () =&gt; {
- console.log('I happen sooner');
- setTimeout( () =&gt; {
- // deeper code
- console.log('I happen later');
- }, 1);
-}, 1);
-</pre>
-
-<h2 id="Специфікації">Специфікації</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Специфікація</th>
- <th scope="col">Статус</th>
- <th scope="col">Коментар</th>
- </tr>
- <tr>
- <td>{{SpecName('ES2015', '#sec-arrow-function-definitions', 'Arrow Function Definitions')}}</td>
- <td>{{Spec2('ES2015')}}</td>
- <td>Початкова виознака.</td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-arrow-function-definitions', 'Arrow Function Definitions')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td></td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Підтримка_веб-переглядачами">Підтримка веб-переглядачами</h2>
-
-<div>
-<div class="hidden">Таблиця сумісності на цій сторінці створена зі структурованих даних. Якщо ви хочете долучитися до розробки цих даних, пропонуйте нам свої pull request до репозиторію <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>.</div>
-
-<p>{{Compat("javascript.functions.arrow_functions")}}</p>
-</div>
-
-<h2 id="Див._також">Див. також</h2>
-
-<ul>
- <li><a href="https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/">"ES6 In Depth: Arrow functions" on hacks.mozilla.org</a></li>
-</ul>
diff --git a/files/uk/web/javascript/reference/functions/get/index.html b/files/uk/web/javascript/reference/functions/get/index.html
deleted file mode 100644
index 00b002aad0..0000000000
--- a/files/uk/web/javascript/reference/functions/get/index.html
+++ /dev/null
@@ -1,175 +0,0 @@
----
-title: гетер
-slug: Web/JavaScript/Reference/Functions/get
-tags:
- - ECMAScript 2015
- - ECMAScript 5
- - JavaScript
- - функції
-translation_of: Web/JavaScript/Reference/Functions/get
----
-<div>{{jsSidebar("Functions")}}</div>
-
-<p>Синтаксис <strong><code>get</code></strong> прив'язує властивість об'єкта до функції, яка викликатиметься під час звернення до властивості.</p>
-
-<div>{{EmbedInteractiveExample("pages/js/functions-getter.html")}}</div>
-
-
-
-<h2 id="Синтаксис">Синтаксис</h2>
-
-<pre class="syntaxbox notranslate">{get <var>prop</var>() { ... } }
-{get [<var>expression</var>]() { ... } }</pre>
-
-<h3 id="Параметри">Параметри</h3>
-
-<dl>
- <dt><code><var>prop</var></code></dt>
- <dd>Ім'я властивості, яка прив'язується до наданої функції.</dd>
- <dt><code><var>expression</var></code></dt>
- <dd>Починаючи з ECMAScript 2015, ви також можете використовувати вираз для обчислюваного імені властивості, яка прив'язується до наданої функції.</dd>
-</dl>
-
-<h2 id="Опис">Опис</h2>
-
-<p>Іноді потрібно надати доступ до властивості, яка повертає динамічно обчислюване значення, або ви можете захотіти відобразити статус внутрішньої змінної без потреби використовувати явні виклики методів. У JavaScript це можна здійснити використанням <em>гетера</em>.</p>
-
-<p>Змінна не може одночасно мати прив'язаний гетер та містити значення, але <em>можливо</em> використати гетер в поєднанні з сетером, щоб створити свого роду псевдовластивість.</p>
-
-<p>Пам'ятайте наступне, працюючи з синтаксисом <code>get</code>:</p>
-
-<ul>
- <li>Він може мати ідентифікатор, який є або числом, або рядком;</li>
- <li>Він повинен мати рівно нуль параметрів (дивіться більше інформації у статті <a class="external" href="http://whereswalden.com/2010/08/22/incompatible-es5-change-literal-getter-and-setter-functions-must-now-have-exactly-zero-or-one-arguments/" rel="external nofollow">Несумісна зміна <abbr title="ECMAScript 5th edition">ES5</abbr>: літеральні функції гетерів та сетерів тепер повинні мати рівно нуль аргументів та один аргумент</a>);</li>
- <li>Він не повинен з'являтись у об'єктному літералі з іншим гетером чи введеними даними для тієї ж властивості(<code>{ get x() { }, get x() { } }</code> та <code>{ x: ..., get x() { } }</code> заборонені).</li>
-</ul>
-
-<h2 id="Приклади">Приклади</h2>
-
-<h3 id="Визначення_гетерів_на_нових_обєктах_у_обєктних_ініціалізаторах">Визначення гетерів на нових об'єктах у об'єктних ініціалізаторах</h3>
-
-<p>Це створить псевдовластивість <code>latest</code> для об'єкта <code>obj</code>, яка повертатиме останній елемент масиву у <code>log</code>.</p>
-
-<pre class="brush: js notranslate">const obj = {
- log: ['приклад','тест'],
- get latest() {
- if (this.log.length === 0) return undefined;
- return this.log[this.log.length - 1];
- }
-}
-console.log(obj.latest); // "тест"
-</pre>
-
-<p>Зауважте, що спроба присвоїти значення <code>latest</code> не змінить її.</p>
-
-<h3 id="Видалення_гетера_оператором_delete">Видалення гетера оператором <code>delete</code></h3>
-
-<p>Якщо вам потрібно прибрати гетер, ви можете його просто {{jsxref("Operators/delete", "видалити")}}:</p>
-
-<pre class="brush: js notranslate">delete <var>obj</var>.latest;
-</pre>
-
-<h3 id="Визначення_гетера_на_існуючому_обєкті_за_допомогою_defineProperty">Визначення гетера на існуючому об'єкті за допомогою <code>defineProperty</code></h3>
-
-<p>Щоб додати гетер до існуючого об'єкта пізніше в будь-який момент, використовуйте {{jsxref("Object.defineProperty()")}}.</p>
-
-<pre class="brush: js notranslate">const o = {a: 0};
-
-Object.defineProperty(o, 'b', { get: function() { return this.a + 1; } });
-
-console.log(o.b) // Запускає гетер, який вертає a + 1 (тобто 1)</pre>
-
-<h3 id="Використання_обчислюваного_імені_властивості">Використання обчислюваного імені властивості</h3>
-
-<pre class="brush: js notranslate">const expr = 'foo';
-
-const obj = {
- get [expr]() { return 'bar'; }
-};
-
-console.log(obj.foo); // "bar"</pre>
-
-<h3 id="Розумні_самопереписувані_ліниві_гетери">Розумні / самопереписувані / ліниві гетери</h3>
-
-<p>Гетери дають можливість <em>визначити</em> властивість об'єкта, але вони не <em>обчислюють</em> значення властивості до звернення. Гетер відкладає вартість обчислення значення, доки значення не знадобиться. Якщо воно ніколи не знадобиться, ви ніколи за це не заплатите.</p>
-
-<p>Додаткова техніка оптимізації, що полягає у відкладені обчислення значення властивості та кешуванні її для пізнішого звернення, створює <strong>розумні (або "<a href="https://uk.wikipedia.org/wiki/%D0%9C%D0%B5%D0%BC%D0%BE%D1%96%D0%B7%D0%B0%D1%86%D1%96%D1%8F">мемоізовані</a>") гетери</strong>. Значення обчислюється під час першого виклику гетера, після чого кешується, а отже, наступні виклики повертають кешоване значення, не переобчислюючи його. Це неймовірно корисно у наступних ситуаціях:</p>
-
-<ul>
- <li>Якщо обчислення значення властивості є дорогим (витрачає багато оперативної пам'яті чи часу процесора, створює потоки виконавців, отримує файл, і т.д.).</li>
- <li>Якщо значення не потрібне вам просто зараз. Воно використовуватиметься пізніше, або в певних випадках не використовуватиметься взагалі.</li>
- <li>Якщо воно використовується, до нього відбувається декілька звернень, і немає потреби його переобчислювати, значення ніколи не змінюється і не потребує переобчислення.</li>
-</ul>
-
-<div class="note">
-<p>Це означає, що не варто писати лінивий гетер для властивості, чиє значення ви плануєте змінювати, бо, якщо гетер лінивий, він не буде його переобчислювати.</p>
-
-<p>Зауважте, що гетери не є ані “лінивими”, ані “мемоізованими” від природи; ви маєте реалізувати цю техніку, якщо вам потрібна така поведінка.</p>
-</div>
-
-<p>У наступному прикладі об'єкт має гетер як особисту властивість. Під час отримання властивості вона видаляється з об'єкта та повторно додається, але цього разу неявно, як властивість-значення. Наприкінці повертається значення.</p>
-
-<pre class="brush: js notranslate">get notifier() {
- delete this.notifier;
- return this.notifier = document.getElementById('bookmarked-notification-anchor');
-},</pre>
-
-<p>Для коду Firefox, дивіться також модуль <code>XPCOMUtils.jsm</code>, який визначає функцію <code><a href="/uk/docs/Mozilla/JavaScript_code_modules/XPCOMUtils.jsm#defineLazyGetter()">defineLazyGetter()</a></code>.</p>
-
-<h3 id="get_проти_defineProperty"><code>get</code> проти <code>defineProperty</code></h3>
-
-<p>Хоча ключове слово <code>get</code> та метод {{jsxref("Object.defineProperty()")}} дають схожі результати, існує тонка різниця між ними при використанні з {{jsxref("classes", "класами")}}.</p>
-
-<p>При використанні <code>get</code>, властивість буде визначена на прототипі екземпляру, в той час як {{jsxref("Object.defineProperty()")}} визначає властивість на екземплярі, до якого застосовується.</p>
-
-<pre class="brush: js notranslate">class Example {
- get hello() {
- return 'привіт';
- }
-}
-
-const obj = new Example();
-console.log(obj.hello);
-// "привіт"
-
-console.log(Object.getOwnPropertyDescriptor(obj, 'hello'));
-// undefined
-
-console.log(
- Object.getOwnPropertyDescriptor(
- Object.getPrototypeOf(obj), 'hello'
- )
-);
-// { configurable: true, enumerable: false, get: function get hello() { return 'привіт'; }, set: undefined }</pre>
-
-<h2 id="Специфікації">Специфікації</h2>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Специфікації</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-method-definitions', 'Method definitions')}}</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Сумісність_з_веб-переглядачами">Сумісність з веб-переглядачами</h2>
-
-
-
-<p>{{Compat("javascript.functions.get")}}</p>
-
-<h2 id="Див._також">Див. також</h2>
-
-<ul>
- <li><a href="/uk/docs/Web/JavaScript/Reference/Functions/set">сетер</a></li>
- <li>{{jsxref("Operators/delete", "delete")}}</li>
- <li>{{jsxref("Object.defineProperty()")}}</li>
- <li>{{jsxref("Object.__defineGetter__", "__defineGetter__")}}</li>
- <li>{{jsxref("Object.__defineSetter__", "__defineSetter__")}}</li>
- <li><a href="/uk/docs/Web/JavaScript/Guide/Working_with_Objects#Визначення_гетерів_та_сетерів">Визначення гетерів та сетерів</a> у посібнику JavaScript</li>
-</ul>
diff --git a/files/uk/web/javascript/reference/functions/index.html b/files/uk/web/javascript/reference/functions/index.html
deleted file mode 100644
index c8edad0b53..0000000000
--- a/files/uk/web/javascript/reference/functions/index.html
+++ /dev/null
@@ -1,605 +0,0 @@
----
-title: Functions
-slug: Web/JavaScript/Reference/Functions
-translation_of: Web/JavaScript/Reference/Functions
----
-<div>AEA{{jsSidebar("Functions")}}</div>
-
-<p>Загалом функція - це "підпрограма", що може бути <em>викликана </em>за допомогою зовнішнього (або внутрішнього у випадку рекурсії) коду. Так само, як і програма, функція складається з послідовності інструкцій, що називаються <em>тілом функції. </em>Функція приймає <em>значення</em> і вертає також <em>значення</em>.<br>
- <br>
- В JavaScript, функції - це об'єкти першого класу (first-class objects). Вони можуть мати <em>властивості</em> (properties) та <em>методи</em> (methods) так само, як і будь-які інші об'єкти. Вирізняє їх від інших об'єктів те, як вони викликаються. Загалом, функції є функціональними об'єктами (<code><a href="/uk/docs/JavaScript/Reference/Global_Objects/Function">Function</a></code> objects).<br>
- <br>
- Додаткові приклади і пояснення, див. також на <a href="/uk/docs/Web/JavaScript/Guide/Functions">JavaScript guide about functions</a>.</p>
-
-<h2 id="Опис">Опис</h2>
-
-<p>Кожна функція в JavaScript є об'єктом. Перегляньте {{jsxref("Function")}}, для отримання інформації про властивості та методи, об'єктів функцій.</p>
-
-<p>Функції не те ж саме, що й процедури. Функція завжди повертає значення, а процедура може не завжди повертати значення.</p>
-
-<p>Щоб повернути значення інше ніж default (за замовчуванням), функція мусить мати <code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/return">return</a></code> оператор, який визначає яке значення має бути повернуто. Функція без оператора return буде повертати значення, яке встановлене за замовчуванням(default).<br>
- <br>
- У випадку, коли конструктор (<a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor">constructor</a>) викликається з оператором <code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/new">new</a></code>, дефолтним значенням стає значення параметра <code>this</code>. Для всіх інших функцій значення, яке буде повертатися за замовчуванням буде {{jsxref("undefined")}}.</p>
-
-<p>Параметри, що передаються при виклику функції, називаються<em>аргументами. </em>Аргументи передаються в функцію за <em>значенням</em>. При зміні значення аргументу, ця зміна жодним чином не відображається в глобальній області видимості або в функціі виклику.<br>
- <br>
- However, object references are values, too, and they are special: if the function changes the referred object's properties, that change is visible outside the function, as shown in the following example:</p>
-
-<pre class="brush: js">/* Оголошення функції 'myFunc' */
-function myFunc(theObject) {
- theObject.brand = "Toyota";
- }
-
- /*
- * Оголошення змінної 'mycar';
- * створення і ініціалізація нового об'єкту;
- * присвоєння об'єкту до 'mycar'
- */
- var mycar = {
- brand: "Honda",
- model: "Accord",
- year: 1998
- };
-
- /* Виведе 'Honda' */
- console.log(mycar.brand);
-
- /* Pass object reference to the function */
- myFunc(mycar);
-
- /*
- * Logs 'Toyota' as the value of the 'brand' property
- * of the object, as changed to by the function.
- */
- console.log(mycar.brand);
-</pre>
-
-<p>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/this"><code>this</code> keyword</a> does not refer to the currently executing function, so you must refer to <code>Function</code> objects by name, even within the function body.</p>
-
-<h2 id="Оголошення_функцій">Оголошення функцій</h2>
-
-<p>Є кілька способів оголошення функції:</p>
-
-<h3 id="The_function_declaration_function_statement">The function declaration (<code>function</code> statement)</h3>
-
-<p>Існує спеціальний синтаксис для оголошення функцій (докладніше див. <a href="/en-US/docs/Web/JavaScript/Reference/Statements/function">function statement</a>): </p>
-
-<pre class="syntaxbox">function <em>name</em>([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {
- <em>statements</em>
-}
-</pre>
-
-<dl>
- <dt><code>name</code></dt>
- <dd>Назва функціі.</dd>
-</dl>
-
-<dl>
- <dt><code>param</code></dt>
- <dd>Назва аргументу, що передається в функцію. Функція може приймати до 255 аргументів.</dd>
-</dl>
-
-<dl>
- <dt><code>statements</code></dt>
- <dd>Інструкціі, що складають тіло функціі.</dd>
-</dl>
-
-<h3 id="The_function_expression_function_expression">The function expression (<code>function</code> expression)</h3>
-
-<p>Функціональний вираз схожиий на оголошення функції (function declaration) і має такий самий синтаксис (докладніше див. <a href="/en-US/docs/Web/JavaScript/Reference/Operators/function">function expression</a>):</p>
-
-<pre class="syntaxbox">function [<em>name</em>]([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {
- <em>statements</em>
-}
-</pre>
-
-<dl>
- <dt><code>name</code></dt>
- <dd>Назва функції. Може бути пропущена, тоді функція стане анонімною.</dd>
-</dl>
-
-<dl>
- <dt><code>param</code></dt>
- <dd>Назва аргументу, що передається в функцію. Функція може приймати до 255 аргументів.</dd>
- <dt><code>statements</code></dt>
- <dd>Інструкціі, що складають тіло функціі.</dd>
-</dl>
-
-<h3 id="The_generator_function_declaration_function*_statement">The generator function declaration (<code>function*</code> statement)</h3>
-
-<div class="note">
-<p><strong>Примітка:</strong>  Generator functions є<em> експериментальною технологією,</em> частиною ECMAScript 6 proposal,  і поки що не підтримуються всіма браузерами.</p>
-</div>
-
-<p>There is a special syntax for generator function declarations (see {{jsxref('Statements/function*', 'function* statement')}} for details):</p>
-
-<pre class="syntaxbox">function* <em>name</em>([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {
- <em>statements</em>
-}
-</pre>
-
-<dl>
- <dt><code>name</code></dt>
- <dd>Назва функції.</dd>
-</dl>
-
-<dl>
- <dt><code>param</code></dt>
- <dd>Назва аргументу, що передається в функцію. Функція може приймати до 255 аргументів.</dd>
-</dl>
-
-<dl>
- <dt><code>statements</code></dt>
- <dd>Інструкціі, що складають тіло функціі.</dd>
-</dl>
-
-<h3 id="The_generator_function_expression_function*_expression">The generator function expression (<code>function*</code> expression)</h3>
-
-<div class="note">
-<p><strong>Примітка:</strong>  Generator functions є<em> експериментальною технологією,</em> частиною ECMAScript 6 proposal,  і поки що не підтримуються всіма браузерами.</p>
-</div>
-
-<p>A generator function expression is similar to and has the same syntax as a generator function declaration (see {{jsxref('Operators/function*', 'function* expression')}} for details):</p>
-
-<pre class="syntaxbox">function* [<em>name</em>]([<em>param</em>[, <em>param</em>[, ... <em>param</em>]]]) {
- <em>statements</em>
-}
-</pre>
-
-<dl>
- <dt><code>name</code></dt>
- <dd>Назва функції. Може бути пропущена, тоді функція стане анонімною.</dd>
-</dl>
-
-<dl>
- <dt><code>param</code></dt>
- <dd>Назва аргументу, що передається в функцію. Функція може приймати до 255 аргументів.</dd>
- <dt><code>statements</code></dt>
- <dd>Інструкціі, що складають тіло функціі.</dd>
-</dl>
-
-<h3 id="The_arrow_function_expression_>">The arrow function expression (=&gt;)</h3>
-
-<div class="note">
-<p><strong>Примітка:</strong> Стрілочні функції (arrow function expressions) є<em> експериментальною технологією,</em> частиною ECMAScript 6 proposal,  і поки що не підтримуються всіма браузерами.</p>
-</div>
-
-<p>Стрілочні функції (arrow function expression) мають коротший синтаксис і лексично прив'язують значення <code>this</code> (докладніше див. <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">arrow functions</a>):</p>
-
-<pre class="syntaxbox">([param[, param]]) =&gt; {
- statements
-}
-
-param =&gt; expression
-</pre>
-
-<dl>
- <dt><code>param</code></dt>
- <dd>Назва аргументу. Якщо функція не має аргументів, це позначається скобками <code>()</code>. Якщо функція приймає тільки один аргумент, скобки можна опустити (як в <code>foo =&gt; 1</code>).</dd>
- <dt><code>statements or expression</code></dt>
- <dd>Декілька інструкції повинні бути в квадратних скобках. Якщо тіло функції містить тільки одну інструкцію, скобки можна опустити. Ця інструкція також є неявним зворотним значенням функції. </dd>
-</dl>
-
-<h3 id="The_Function_constructor">The <code>Function</code> constructor</h3>
-
-<div class="note">
-<p><strong>Примітка:</strong> Використання конструктора <code>Function</code> для створення  функцій не рекомендується, оскільки воно потребує перетворення тіла функції на строку. Це може перешкоджати деяким оптимізаціям  JS двіжка та створювати інші проблеми.</p>
-</div>
-
-<p class="syntaxbox">Як і всі інші об'єкти, об'єкти {{jsxref("Function")}} можна створювати за допомогою оператора  <code>new</code>:</p>
-
-<pre class="syntaxbox">new Function (<em>arg1</em>, <em>arg2</em>, ... <em>argN</em>, <em>functionBody</em>)</pre>
-
-<dl>
- <dt><code>arg1, arg2, ... arg<em>N</em></code></dt>
- <dd>Zero or more names to be used by the function as formal parameters. Each must be a proper JavaScript identifier.</dd>
-</dl>
-
-<dl>
- <dt><code>functionBody</code></dt>
- <dd>Cтрока, що містить інструкції, що складають тіло функції.</dd>
-</dl>
-
-<p>Invoking the <code>Function</code> constructor as a function (without using the <code>new</code> operator) has the same effect as invoking it as a constructor.</p>
-
-<h3 id="The_GeneratorFunction_constructor">The <code>GeneratorFunction</code> constructor</h3>
-
-<div class="note">
-<p><strong>Note:</strong> <code>GeneratorFunction</code> не є глобальним об'єктом, але може бути отриманий з generator function instance (докладніше див. {{jsxref("GeneratorFunction")}}):</p>
-</div>
-
-<div class="note">
-<p><strong>Примітка:</strong> Використання конструктора <code>GeneratorFunction</code> для створення  функцій не рекомендується, оскільки воно потребує перетворення тіла функції на строку. Це може перешкоджати деяким оптимізаціям  JS двіжка та створювати інші проблеми.</p>
-</div>
-
-<p>Як і всі інші об'єкти, об'єкти {{jsxref("GeneratorFunction")}}  можна створювати за допомогою оператора  <code>new</code>:</p>
-
-<pre class="syntaxbox">new GeneratorFunction (<em>arg1</em>, <em>arg2</em>, ... <em>argN</em>, <em>functionBody</em>)
-</pre>
-
-<dl>
- <dt><code>arg1, arg2, ... arg<em>N</em></code></dt>
- <dd>Zero or more names to be used by the function as formal argument names. Each must be a string that conforms to the rules for a valid JavaScript identifier or a list of such strings separated with a comma; for example "<code>x</code>", "<code>theValue</code>", or "<code>a,b</code>".</dd>
-</dl>
-
-<dl>
- <dt><code>functionBody</code></dt>
- <dd>A string containing the JavaScript statements comprising the function definition.</dd>
-</dl>
-
-<p>Invoking the <code>Function</code> constructor as a function (without using the <code>new</code> operator) has the same effect as invoking it as a constructor.</p>
-
-<h2 id="Параметри_функції">Параметри функції</h2>
-
-<div class="note">
-<p><strong>Примітка:</strong> Default and rest parameters є<em> експериментальною технологією,</em> частиною ECMAScript 6 proposal,  і поки що не підтримуються всіма браузерами.</p>
-</div>
-
-<h3 id="Default_parameters">Default parameters</h3>
-
-<p>Default function parameters allow formal parameters to be initialized with default values if no value or <code>undefined</code> is passed. For more details, see<a href="/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters"> default parameters</a>.</p>
-
-<h3 id="Rest_parameters">Rest parameters</h3>
-
-<p>The rest parameter syntax allows to represent an indefinite number of arguments as an array. For more details, see <a href="/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters">rest parameters</a>.</p>
-
-<h2 id="Обєкт_arguments">Об'єкт <code>arguments</code></h2>
-
-<p>До аргументів функції можна звернутися всередині самої функції за допомогою об'єкта <code>arguments</code>. (Докладніше див. <a href="/en-US/docs/Web/JavaScript/Reference/Functions/arguments">arguments</a>)</p>
-
-<ul>
- <li><code><a href="/en-US/docs/JavaScript/Reference/Functions_and_function_scope/arguments">arguments</a></code>: An array-like object containing the arguments passed to the currently executing function.</li>
- <li><code><a href="/en-US/docs/JavaScript/Reference/Functions_and_function_scope/arguments/callee">arguments.callee</a></code> {{Deprecated_inline}}: The currently executing function.</li>
- <li><code><a href="/en-US/docs/JavaScript/Reference/Functions_and_function_scope/arguments/caller">arguments.caller</a></code> {{Obsolete_inline}} : The function that invoked the currently executing function.</li>
- <li><code><a href="/en-US/docs/JavaScript/Reference/Functions_and_function_scope/arguments/length">arguments.length</a></code>: The number of arguments passed to the function.</li>
-</ul>
-
-<h2 id="Defining_method_functions">Defining method functions</h2>
-
-<h3 id="Getter_and_setter_functions">Getter and setter functions</h3>
-
-<p>You can define getters (accessor methods) and setters (mutator methods) on any standard built-in object or user-defined object that supports the addition of new properties. The syntax for defining getters and setters uses the object literal syntax.</p>
-
-<dl>
- <dt><a href="/en-US/docs/Web/JavaScript/Reference/Functions/get">get</a></dt>
- <dd>
- <p>Binds an object property to a function that will be called when that property is looked up.</p>
- </dd>
- <dt><a href="/en-US/docs/Web/JavaScript/Reference/Functions/set">set</a></dt>
- <dd>Binds an object property to a function to be called when there is an attempt to set that property.</dd>
-</dl>
-
-<h3 id="Method_definition_syntax">Method definition syntax</h3>
-
-<div class="note">
-<p><strong>Note:</strong> <em>Method definitions are experimental technology,</em> part of the ECMAScript 6 proposal, and are not widely supported by browsers yet.</p>
-</div>
-
-<p>Starting with ECMAScript 6, you are able to define own methods in a shorter syntax, similar to the getters and setters. See <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions">method definitions</a> for more information.</p>
-
-<pre class="brush: js">var obj = {
- foo() {},
-  bar() {}
-};</pre>
-
-<h2 id="Function_constructor_vs._function_declaration_vs._function_expression"><code>Function</code> constructor vs. function declaration vs. function expression</h2>
-
-<p>Compare the following:</p>
-
-<p>A function defined with the <code>Function</code> constructor assigned to the variable <code>multiply:</code></p>
-
-<pre class="brush: js">function multiply(x, y) {
- return x * y;
-}
-</pre>
-
-<p>A <em>function expression</em> of an anonymous function assigned to the variable <code>multiply:</code></p>
-
-<pre class="brush: js">var multiply = function(x, y) {
- return x * y;
-};
-</pre>
-
-<p>A <em>function expression</em> of a function named <code>func_name</code> assigned to the variable <code>multiply:</code></p>
-
-<pre class="brush: js">var multiply = function func_name(x, y) {
- return x * y;
-};
-</pre>
-
-<h3 id="Відмінності">Відмінності</h3>
-
-<p>All do approximately the same thing, with a few subtle differences:</p>
-
-<p>There is a distinction between the function name and the variable the function is assigned to. The function name cannot be changed, while the variable the function is assigned to can be reassigned. The function name can be used only within the function's body. Attempting to use it outside the function's body results in an error (or <code>undefined</code> if the function name was previously declared via a <code>var</code> statement). For example:</p>
-
-<pre class="brush: js">var y = function x() {};
-alert(x); // throws an error
-</pre>
-
-<p>The function name also appears when the function is serialized via <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/toString"><code>Function</code>'s toString method</a>.</p>
-
-<p>On the other hand, the variable the function is assigned to is limited only by its scope, which is guaranteed to include the scope where the function is declared in.</p>
-
-<p>As the 4th example shows, the function name can be different from the variable the function is assigned to. They have no relation to each other.A function declaration also creates a variable with the same name as the function name. Thus, unlike those defined by function expressions, functions defined by function declarations can be accessed by their name in the scope they were defined in:</p>
-
-<p>A function defined by '<code>new Function'</code> does not have a function name. However, in the <a href="/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a> JavaScript engine, the serialized form of the function shows as if it has the name "anonymous". For example, <code>alert(new Function())</code> outputs:</p>
-
-<pre class="brush: js">function anonymous() {
-}
-</pre>
-
-<p>Since the function actually does not have a name, <code>anonymous</code> is not a variable that can be accessed within the function. For example, the following would result in an error:</p>
-
-<pre class="brush: js">var foo = new Function("alert(anonymous);");
-foo();
-</pre>
-
-<p>Unlike functions defined by function expressions or by the <code>Function</code> constructor, a function defined by a function declaration can be used before the function declaration itself. For example:</p>
-
-<pre class="brush: js">foo(); // alerts FOO!
-function foo() {
- alert('FOO!');
-}
-</pre>
-
-<p>A function defined by a function expression inherits the current scope. That is, the function forms a closure. On the other hand, a function defined by a <code>Function</code> constructor does not inherit any scope other than the global scope (which all functions inherit).</p>
-
-<p>Functions defined by function expressions and function declarations are parsed only once, while those defined by the <code>Function</code> constructor are not. That is, the function body string passed to the <code>Function</code> constructor must be parsed each and every time the constructor is called. Although a function expression creates a closure every time, the function body is not reparsed, so function expressions are still faster than "<code>new Function(...)</code>". Therefore the <code>Function</code> constructor should generally be avoided whenever possible.</p>
-
-<p>It should be noted, however, that function expressions and function declarations nested within the function generated by parsing a <code>Function constructor</code> 's string aren't parsed repeatedly. For example:</p>
-
-<pre class="brush: js">var foo = (new Function("var bar = \'FOO!\';\nreturn(function() {\n\talert(bar);\n});"))();
-foo(); // The segment "function() {\n\talert(bar);\n}" of the function body string is not re-parsed.</pre>
-
-<p>A function declaration is very easily (and often unintentionally) turned into a function expression. A function declaration ceases to be one when it either:</p>
-
-<ul>
- <li>becomes part of an expression</li>
- <li>is no longer a "source element" of a function or the script itself. A "source element" is a non-nested statement in the script or a function body:</li>
-</ul>
-
-<pre class="brush: js">var x = 0; // source element
-if (x == 0) { // source element
- x = 10; // not a source element
- function boo() {} // not a source element
-}
-function foo() { // source element
- var y = 20; // source element
- function bar() {} // source element
- while (y == 10) { // source element
- function blah() {} // not a source element
- y++; // not a source element
- }
-}
-</pre>
-
-<h3 id="Приклади">Приклади</h3>
-
-<pre class="brush: js">// function declaration
-function foo() {}
-
-// function expression
-(function bar() {})
-
-// function expression
-x = function hello() {}
-
-
-if (x) {
- // function expression
- function world() {}
-}
-
-
-// function declaration
-function a() {
- // function declaration
- function b() {}
- if (0) {
- // function expression
- function c() {}
- }
-}
-</pre>
-
-<h2 id="Conditionally_defining_a_function">Conditionally defining a function</h2>
-
-<p>Functions can be conditionally defined using either //function statements// (an allowed extension to the <a href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMA-262 Edition 3</a> standard) or the <code>Function</code> constructor. Please note that such <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=609832">function statements are no longer allowed in ES5 strict</a>. Additionally, this feature does not work consistently cross-browser, so you should not rely on it.</p>
-
-<p>In the following script, the <code>zero</code> function is never defined and cannot be invoked, because '<code>if (0)</code>' evaluates its condition to false:</p>
-
-<pre class="brush: js">if (0) {
- function zero() {
- document.writeln("This is zero.");
- }
-}
-</pre>
-
-<p>If the script is changed so that the condition becomes '<code>if (1)</code>', function <code>zero</code> is defined.</p>
-
-<p>Note: Although this kind of function looks like a function declaration, it is actually an expression (or statement), since it is nested within another statement. See differences between function declarations and function expressions.</p>
-
-<p>Note: Some JavaScript engines, not including <a href="/en-US/docs/SpiderMonkey">SpiderMonkey</a>, incorrectly treat any function expression with a name as a function definition. This would lead to <code>zero</code> being defined, even with the always-false <code>if</code> condition. A safer way to define functions conditionally is to define the function anonymously and assign it to a variable:</p>
-
-<pre class="brush: js">if (0) {
- var zero = function() {
- document.writeln("This is zero.");
- }
-}
-</pre>
-
-<h2 id="Приклади_2">Приклади</h2>
-
-<h3 id="Returning_a_formatted_number">Returning a formatted number</h3>
-
-<p>The following function returns a string containing the formatted representation of a number padded with leading zeros.</p>
-
-<pre class="brush: js">// This function returns a string padded with leading zeros
-function padZeros(num, totalLen) {
- var numStr = num.toString(); // Initialize return value as string
- var numZeros = totalLen - numStr.length; // Calculate no. of zeros
- for (var i = 1; i &lt;= numZeros; i++) {
- numStr = "0" + numStr;
- }
- return numStr;
-}
-</pre>
-
-<p>The following statements call the padZeros function.</p>
-
-<pre class="brush: js">var result;
-result = padZeros(42,4); // returns "0042"
-result = padZeros(42,2); // returns "42"
-result = padZeros(5,4); // returns "0005"
-</pre>
-
-<h3 id="Determining_whether_a_function_exists">Determining whether a function exists</h3>
-
-<p>You can determine whether a function exists by using the <code>typeof</code> operator. In the following example, a test is peformed to determine if the <code>window</code> object has a property called <code>noFunc</code> that is a function. If so, it is used; otherwise some other action is taken.</p>
-
-<pre class="brush: js"> if ('function' == typeof window.noFunc) {
- // use noFunc()
- } else {
- // do something else
- }
-</pre>
-
-<p>Note that in the <code>if</code> test, a reference to <code>noFunc</code> is used—there are no brackets "()" after the function name so the actual function is not called.</p>
-
-<h2 id="Специфікації">Специфікації</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Специфікація</th>
- <th scope="col">Статус</th>
- <th scope="col">Коментар</th>
- </tr>
- <tr>
- <td>{{SpecName('ES1')}}</td>
- <td>{{Spec2('ES1')}}</td>
- <td>Initial definition. Implemented in JavaScript 1.0</td>
- </tr>
- <tr>
- <td>{{SpecName('ES5.1', '#sec-13', 'Function Definition')}}</td>
- <td>{{Spec2('ES5.1')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('ES6', '#sec-function-definitions', 'Function definitions')}}</td>
- <td>{{Spec2('ES6')}}</td>
- <td>New: Arrow functions, Generator functions, default parameters, rest parameters.</td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-function-definitions', 'Function definitions')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td></td>
- </tr>
- </tbody>
-</table>
-
-<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>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- </tr>
- <tr>
- <td>Generator function</td>
- <td>39</td>
- <td>{{CompatGeckoDesktop("26.0")}}</td>
- <td>{{CompatUnknown}}</td>
- <td>26</td>
- <td>{{CompatUnknown}}</td>
- </tr>
- <tr>
- <td>Arrow function</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatGeckoDesktop("22.0")}}</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>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- <td>{{CompatVersionUnknown}}</td>
- </tr>
- <tr>
- <td>Generator function</td>
- <td>{{CompatUnknown}}</td>
- <td>39</td>
- <td>{{CompatGeckoMobile("26.0")}}</td>
- <td>{{CompatUnknown}}</td>
- <td>26</td>
- <td>{{CompatUnknown}}</td>
- </tr>
- <tr>
- <td>Arrow function</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatGeckoMobile("22.0")}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- </tr>
- </tbody>
-</table>
-</div>
-
-<h2 id="Також_див.">Також див.</h2>
-
-<ul>
- <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("Function")}}</li>
- <li>{{jsxref("GeneratorFunction")}}</li>
- <li>{{jsxref("Functions/Arrow_functions", "Arrow functions")}}</li>
- <li>{{jsxref("Functions/Default_parameters", "Default parameters")}}</li>
- <li>{{jsxref("Functions/rest_parameters", "Rest parameters")}}</li>
- <li>{{jsxref("Functions/arguments", "Arguments object")}}</li>
- <li>{{jsxref("Functions/get", "getter")}}</li>
- <li>{{jsxref("Functions/set", "setter")}}</li>
- <li>{{jsxref("Functions/Method_definitions", "Method definitions")}}</li>
- <li><a href="/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope" title="JavaScript/Reference/Functions_and_function_scope">Functions and function scope</a></li>
-</ul>
diff --git a/files/uk/web/javascript/reference/functions/method_definitions/index.html b/files/uk/web/javascript/reference/functions/method_definitions/index.html
deleted file mode 100644
index 3930fff286..0000000000
--- a/files/uk/web/javascript/reference/functions/method_definitions/index.html
+++ /dev/null
@@ -1,219 +0,0 @@
----
-title: Method definitions
-slug: Web/JavaScript/Reference/Functions/Method_definitions
-tags:
- - ECMAScript 2015
- - JavaScript
- - Об'єкт
- - Синтаксис
- - Скорочення
- - функції
-translation_of: Web/JavaScript/Reference/Functions/Method_definitions
----
-<div>{{JsSidebar("Functions")}}</div>
-
-<p>Починаючи з ECMAScript 2015, з'явився скорочений спосіб визначення методів для обєктів. Який допоможе вам простіше привязати функцію до імя методу обєкта.</p>
-
-<div>{{EmbedInteractiveExample("pages/js/functions-definitions.html")}}</div>
-
-
-
-<h2 id="Синтаксис">Синтаксис</h2>
-
-<pre class="syntaxbox notranslate">var obj = {
- <var>property</var>( <var>parameters…</var> ) {},
- *<var>generator</var>( <var>parameters…</var> ) {},
- async property( <var>parameters…</var> ) {},
- async* generator( <var>parameters…</var> ) {},
-
- // з обчисленими ключами:
- [property]( <var>parameters…</var> ) {},
- *[generator]( <var>parameters…</var> ) {},
- async [property]( <var>parameters…</var> ) {},
-
- // порівняйте getter/setter синтаксис:
- get <var>property</var>() {},
- set <var>property</var>(<var>value</var>) {}
-};
-</pre>
-
-<h2 id="Опис">Опис</h2>
-
-<p>Скорочений синтаксис подібний до синтаксису <a href="/en-US/docs/Web/JavaScript/Reference/Functions/get">getter</a> і <a href="/en-US/docs/Web/JavaScript/Reference/Functions/set">setter</a> оголошенних в ECMAScript 2015.</p>
-
-<p>Отже, цей код:</p>
-
-<pre class="brush: js notranslate">var obj = {
- foo: function() {
- /* код */
- },
- bar: function() {
- /* код */
- }
-};
-</pre>
-
-<p>Ви здатні скоротити до:</p>
-
-<pre class="brush: js notranslate">var obj = {
- foo() {
- /* код */
- },
- bar() {
- /* код */
- }
-};
-
-</pre>
-
-<h3 id="Генераторні_методи">Генераторні методи</h3>
-
-<p><a href="/en-US/docs/Web/JavaScript/Reference/Statements/function*">Генераторні методи</a> також можуть бути визначенні за допомогою скороченного синтаксису. Користуючить ними:</p>
-
-<ul>
- <li>зірочка (*)  повинна бути перед іменем генераторного методу. Тобто, <code>* g(){}</code> - це працюватиме, <code>g *(){}</code> - це ні.</li>
- <li>всі не генераторні визначення методів не можуть використовувати ключове слово <code>yield</code>. Це означає, що <a href="/en-US/docs/Web/JavaScript/Reference/Statements/Legacy_generator_function">застарілі генераторні функції</a> також не працюватимуть і викинуть {{jsxref("SyntaxError")}}. Завжди використовуйте <code>yield</code> разом із зірочкою (*).</li>
-</ul>
-
-<pre class="brush: js;highlight[12] notranslate">// Використовуючи названу властивіть
-var obj2 = {
- g: function* () {
- var index = 0;
- while (true)
- yield index++;
- }
-};
-
-// Ідентичний обєкт використовуючи скорочений синтаксис
-var obj2 = {
- * g() {
- var index = 0;
- while (true)
- yield index++;
- }
-};
-
-var it = obj2.g();
-console.log(it.next().value); // 0
-console.log(it.next().value); // 1</pre>
-
-<h3 id="Async_методи">Async методи</h3>
-
-<p>{{jsxref("Statements/async_function", "Async methods", "", 1)}} також можуть бути визначенні використовуючи скорочення.</p>
-
-<pre class="brush: js;highlight[12] notranslate">// Використовуючи названу властивіть
-var obj3 = {
- f: async function () {
- await some_promise;
- }
-};
-
-// Ідентичний обєкт використовуючи скорочений синтаксис
-var obj3 = {
- async f() {
- await some_promise;
- }
-};
-</pre>
-
-<h3 id="Async_генераторні_методи">Async генераторні методи</h3>
-
-<p><a href="/en-US/docs/Web/JavaScript/Reference/Statements/function*">Генераторні методи</a> також можуть бути {{jsxref("Statements/async_function", "async", "", 1)}}.</p>
-
-<pre class="brush: js notranslate">var obj4 = {
- f: async function* () {
- yield 1;
- yield 2;
- yield 3;
- }
-};
-
-// Ідентичний обєкт використовуючи скорочений синтаксис
-var obj4 = {
- async* f() {
- yield 1;
- yield 2;
- yield 3;
- }
-};</pre>
-
-<h3 id="Визначенні_методи_за_допомогою_скорочення_-_не_є_конструкторами">Визначенні методи за допомогою скорочення - не є конструкторами</h3>
-
-<p>Любі визначенні методи за допомогою скорочення не є конструктором і викинуть {{jsxref("TypeError")}}, якщо ви попробуєте створити <span class="tlid-translation translation" lang="uk"><span title="">екземпляр обєкту за допомогою них</span></span>.</p>
-
-<pre class="brush: js example-bad notranslate">var obj = {
- method() {}
-};
-new obj.method; // TypeError: obj.method is not a constructor
-
-var obj = {
- * g() {}
-};
-new obj.g; // TypeError: obj.g is not a constructor (changed in ES2016)
-</pre>
-
-<h2 id="Приклади">Приклади</h2>
-
-<h3 id="Базові_випадки">Базові випадки</h3>
-
-<pre class="brush: js;highlight[3] notranslate">var obj = {
- a: 'foo',
- b() { return this.a; }
-};
-console.log(obj.b()); // "foo"
-</pre>
-
-<h3 id="Обчисленні_імена_властивостей">Обчисленні імена властивостей</h3>
-
-<p>Скороченний синтаксис також підтримує обчисленні імена властивостей.</p>
-
-<pre class="brush: js;highlight[4] notranslate">var bar = {
- foo0: function() { return 0; },
- foo1() { return 1; },
- ['foo' + 2]() { return 2; }
-};
-
-console.log(bar.foo0()); // 0
-console.log(bar.foo1()); // 1
-console.log(bar.foo2()); // 2</pre>
-
-<h2 id="Специфікації">Специфікації</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Specification</th>
- <th scope="col">Status</th>
- <th scope="col">Comment</th>
- </tr>
- <tr>
- <td>{{SpecName('ES2015', '#sec-method-definitions', 'Method definitions')}}</td>
- <td>{{Spec2('ES2015')}}</td>
- <td>Initial definition.</td>
- </tr>
- <tr>
- <td>{{SpecName('ES2016', '#sec-method-definitions', 'Method definitions')}}</td>
- <td>{{Spec2('ES2016')}}</td>
- <td>Changed that generator methods should also not have a [[Construct]] trap and will throw when used with <code>new</code>.</td>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-method-definitions', 'Method definitions')}}</td>
- <td>{{Spec2('ESDraft')}}</td>
- <td></td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Підтримка_браузерів">Підтримка браузерів</h2>
-
-
-
-<p>{{Compat("javascript.functions.method_definitions")}}</p>
-
-<h2 id="Дивитися_також"><span class="tlid-translation translation" lang="uk"><span title="">Дивитися також</span></span></h2>
-
-<ul>
- <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Functions/get">get</a></code></li>
- <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Functions/set">set</a></code></li>
- <li><a href="/en-US/docs/Web/JavaScript/Reference/Lexical_grammar">Lexical grammar</a></li>
-</ul>
diff --git a/files/uk/web/javascript/reference/functions/rest_parameters/index.html b/files/uk/web/javascript/reference/functions/rest_parameters/index.html
deleted file mode 100644
index e659cebeeb..0000000000
--- a/files/uk/web/javascript/reference/functions/rest_parameters/index.html
+++ /dev/null
@@ -1,212 +0,0 @@
----
-title: Залишкові параметри
-slug: Web/JavaScript/Reference/Functions/rest_parameters
-tags:
- - JavaScript
- - Rest
- - параметри
- - функції
-translation_of: Web/JavaScript/Reference/Functions/rest_parameters
-original_slug: Web/JavaScript/Reference/Functions/решта_параметрів
----
-<div>{{jsSidebar("Functions")}}</div>
-
-<div>Синтаксис <strong>залишкових параметрів</strong> дозволяє представити невизначену кількість аргументів у вигляді масиву.</div>
-
-<div></div>
-
-<p>{{EmbedInteractiveExample("pages/js/functions-restparameters.html")}}</p>
-
-<div class="hidden">
-<p>The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
-</div>
-
-<h2 id="Синтаксис">Синтаксис</h2>
-
-<pre class="syntaxbox notranslate">function f(a, b, ...theArgs) {
- // ...
-}
-</pre>
-
-<h2 id="Опис">Опис</h2>
-
-<p>Перед останнім параметром функції може стояти <code>...</code>, в результаті решта аргументів (наданих користувачем) будуть розміщені у  "стандартному" масиві JavaScript.</p>
-
-<p>Лише останній параметр може бути "залишковим".</p>
-
-<pre class="brush: js notranslate">function myFun(a, b, ...manyMoreArgs) {
- console.log("a", a);
- console.log("b", b);
- console.log("manyMoreArgs", manyMoreArgs);
-}
-
-myFun("один", "два", "три", "чорити", "п'ять", "шість");
-
-// Виведе:
-// a, один
-// b, два
-// manyMoreArgs, ["три", "чотири", "п'ять", "шість"]</pre>
-
-<h3 id="Різниця_між_залишковими_параметрами_та_обєктом_arguments">Різниця між залишковими параметрами та об'єктом <code>arguments</code></h3>
-
-<p>Існують три основні відмінності між залишковими параметрами та об'єктом {{jsxref("Functions/arguments", "arguments")}}:</p>
-
-<ul>
- <li>залишковими є лише ті параметри, яким не надали окремого імені, в той час, як об'єкт <code>arguments</code> містить усі аргументи, передані у функцію;</li>
- <li>об'єкт <code>arguments</code> не є справжнім масивом, в той час, як залишкові параметри є екземплярами {{jsxref("Global_Objects/Array", "Array")}}, тобто, методи на кшталт {{jsxref("Array.sort", "sort")}}, {{jsxref("Array.map", "map")}}, {{jsxref("Array.forEach", "forEach")}} чи {{jsxref("Array/pop", "pop")}} можуть викликатись безпосередньо на них;</li>
- <li>об'єкт <code>arguments</code> має також власну, специфічну функціональність (наприклад, властивість <code>callee</code>).</li>
-</ul>
-
-<h3 id="Від_arguments_до_масиву">Від arguments до масиву</h3>
-
-<p>Залишкові параметри були запроваджені, щоб зменшити кількість шаблонного коду, спричиненого об'єктом arguments.</p>
-
-<pre class="brush: js notranslate">// До появи залишкових параметрів, "arguments" можна було перетворити на масив таким чином:
-
-function f(a, b) {
-
- let normalArray = Array.prototype.slice.call(arguments);
- // -- або --
- let normalArray = [].slice.call(arguments);
- // -- або --
- let normalArray = Array.from(arguments);
-
- let first = normalArray.shift(); // OK, вертає перший аргумент
- let first = arguments.shift(); // ERROR (arguments не є справжнім масивом)
-}
-
-// Тепер ми легко можемо отримати звичайний масив за допомогою залишкових параметрів
-
-function f(...args) {
- let normalArray = args;
- let first = normalArray.shift(); // OK, вертає перший аргумент
-}</pre>
-
-<h2 id="Приклади">Приклади</h2>
-
-<h3 id="Використання_залишкових_параметрів">Використання залишкових параметрів</h3>
-
-<p>У цьому прикладі перший аргумент відповідає <code>"a"</code>, а другий <code>"b"</code>, отже, ці іменовані аргументи можуть використовуватись як звичайні.</p>
-
-<p>Однак, третій аргумент, <code>"manyMoreArgs"</code>, буде масивом, який містить 3-й, 4-й, 5-й, 6-й ... n-й -- стільки аргументів, скільки надасть користувач.</p>
-
-<pre class="brush: js notranslate">function myFun(a, b, ...manyMoreArgs) {
- console.log("a", a);
- console.log("b", b);
- console.log("manyMoreArgs", manyMoreArgs);
-}
-
-myFun("один", "два", "три", "чотири", "п'ять", "шість");
-
-// a, один
-// b, два
-// manyMoreArgs, ["три", "чотири", "п'ять", "шість"]</pre>
-
-<p>Нижче... хоча тут всього одне значення, останній аргумент все одно додається у масив.</p>
-
-<pre class="brush: js notranslate">// використовуємо ту саму функцію з наведеного вище прикладу
-
-myFun("один", "два", "три");
-
-// a, один
-// b, два
-// manyMoreArgs, ["три"]</pre>
-
-<p>Нижче... третій аргумент не був переданий, але "manyMoreArgs" все одно є масивом (хоча й порожнім).</p>
-
-<pre class="brush: js notranslate">// використовуємо ту саму функцію з наведеного вище прикладу
-
-myFun("один", "два");
-
-// a, один
-// b, два
-// manyMoreArgs, []</pre>
-
-<h3 id="Кількість_аргументів">Кількість аргументів</h3>
-
-<p>Оскільки <code>theArgs</code> є масивом, кількість його елементів надається властивістю <code>length</code>:</p>
-
-<pre class="brush: js notranslate">function fun1(...theArgs) {
- console.log(theArgs.length);
-}
-
-fun1() // 0
-fun1(5) // 1
-fun1(5, 6, 7) // 3</pre>
-
-<h3 id="Звичайний_параметр_та_залишкові_параметри">Звичайний параметр та залишкові параметри</h3>
-
-<p>У наступному прикладі залишковий параметр використовується, щоб зібрати усі аргументи після першого у масиві. Далі кожен з них помножується на перший параметр, і масив повертається:</p>
-
-<pre class="brush: js notranslate">function multiply(multiplier, ...theArgs) {
- return theArgs.map(function(element) {
- return multiplier * element;
- });
-}
-
-let arr = multiply(2, 1, 2, 3);
-console.log(arr); // [2, 4, 6]</pre>
-
-<h3 id="Використання_з_обєктом_arguments">Використання з об'єктом arguments</h3>
-
-<p>Методи <code>Array</code> можуть використовуватись на залишкових параметрах, але не на об'єкті <code>arguments</code>:</p>
-
-<pre class="brush: js notranslate">function sortRestArgs(...theArgs) {
- var sortedArgs = theArgs.sort();
- return sortedArgs;
-}
-
-console.log(sortRestArgs(5, 3, 7, 1)); // виводить [1, 3, 5, 7]
-
-function sortArguments() {
- var sortedArgs = arguments.sort();
- return sortedArgs; // цього ніколи не станеться
-}
-
-// викидає TypeError: arguments.sort is not a function
-console.log(sortArguments(5, 3, 7, 1));
-</pre>
-
-<p>Щоб скористатись методами <code>Array</code> на об'єкті <code>arguments</code>, він спочатку має бути перетворений на справжній масив.</p>
-
-<pre class="brush: js notranslate">function sortArguments() {
- var args = Array.from(arguments);
- var sortedArgs = args.sort();
- return sortedArgs;
-}
-console.log(sortArguments(5, 3, 7, 1)); // [1, 3, 5, 7]</pre>
-
-<h2 id="Специфікації">Специфікації</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Специфікація</th>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-function-definitions', 'Function Definitions')}}</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Сумісність_з_веб-переглядачами">Сумісність з веб-переглядачами</h2>
-
-<div>
-<div>
-
-
-<p>{{Compat("javascript.functions.rest_parameters")}}</p>
-</div>
-</div>
-
-<h2 id="Див._також">Див. також</h2>
-
-<ul>
- <li><a href="/uk/docs/Web/JavaScript/Reference/Operators/Spread_syntax" title="spread operator">Оператор розкладу</a> (також ‘<code>...</code>’)</li>
- <li><a href="/uk/docs/Web/JavaScript/Reference/Functions/arguments" title="arguments">Об'єкт arguments</a></li>
- <li><a href="/uk/docs/Web/JavaScript/Reference/Global_Objects/Array" title="Array">Array</a></li>
- <li><a href="/uk/docs/Web/JavaScript/Reference/Functions" title="Functions and function scope">Функції</a></li>
- <li><a class="external" href="http://wiki.ecmascript.org/doku.php?id=harmony:rest_parameters">Original proposal at ecmascript.org</a></li>
- <li><a class="external" href="http://javascriptweblog.wordpress.com/2011/01/18/javascripts-arguments-object-and-beyond/">JavaScript arguments object and beyond</a></li>
- <li><a href="/uk/docs/Web/JavaScript/Reference/Operators/Деструктуризація">Деструктуризаційне присвоєння</a></li>
-</ul>
diff --git a/files/uk/web/javascript/reference/functions/set/index.html b/files/uk/web/javascript/reference/functions/set/index.html
deleted file mode 100644
index b26e0e2824..0000000000
--- a/files/uk/web/javascript/reference/functions/set/index.html
+++ /dev/null
@@ -1,152 +0,0 @@
----
-title: сетер
-slug: Web/JavaScript/Reference/Functions/set
-tags:
- - ECMAScript 2015
- - ECMAScript 5
- - JavaScript
- - set
- - функції
-translation_of: Web/JavaScript/Reference/Functions/set
----
-<div>{{jsSidebar("Functions")}}</div>
-
-<p>Оператор <strong><code>set</code></strong> прив'язує властивість об'єкта до функції, яка буде викликана під час спроби присвоїти значення даній властивості.</p>
-
-<p>{{EmbedInteractiveExample("pages/js/functions-setter.html")}}</p>
-
-<div class="hidden">
-<p>The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
-</div>
-
-<h2 id="Синтаксис">Синтаксис</h2>
-
-<pre class="syntaxbox notranslate">{set <em>prop</em>(<em>val</em>) { . . . }}
-{set [expression](<em>val</em>) { . . . }}</pre>
-
-<h3 id="Параметри">Параметри</h3>
-
-<dl>
- <dt><em><code>prop</code></em></dt>
- <dd>Ім'я властивості, котра має бути прив'язана до даної функції.</dd>
-</dl>
-
-<dl>
- <dt><em><code>val</code></em></dt>
- <dd>Псевдонім змінної, що містить значення, для якого виконується спроба присвоїти його властивості <em><code>prop</code></em>.</dd>
- <dt><em>expression</em></dt>
- <dd>Починаючи від ECMAScript 2015, можна також використовувати вираз для обчислюваного імені властивості, до якої буде прив'язана дана функція.</dd>
-</dl>
-
-<h2 id="Опис">Опис</h2>
-
-<p>У JavaScript сетер можна використати для виконання функції під час здійснення спроби змінити певну властивість. Найчастіше сетери використовуються у поєднанні з ґетерами для створення свого роду псевдовластивостей. Не можна водночас мати сетера на властивості, яка містить фактичне значення.</p>
-
-<p>Зауважте особливість використання синтаксису <code>set</code>:</p>
-
-<div>
-<ul>
- <li>Він може мати ідентифікатор, який є або числом, або рядком;</li>
- <li>Він повинен мати рівно один параметр (дивіться більше інформації у статті <a href="http://whereswalden.com/2010/08/22/incompatible-es5-change-literal-getter-and-setter-functions-must-now-have-exactly-zero-or-one-arguments/" rel="external nofollow noopener">Несумісна зміна <abbr title="ECMAScript 5th edition">ES5</abbr>: літеральні функції гетерів та сетерів тепер повинні мати рівно нуль аргументів та один аргумент</a>);</li>
- <li>Він не повинен з'являтись у об'єктному літералі з іншим сетером чи введеними даними для тієї ж властивості.<br>
- ( <code>{ set x(v) { }, set x(v) { } }</code> та <code>{ x: ..., set x(v) { } }</code> заборонені)</li>
-</ul>
-</div>
-
-<h2 id="Приклади">Приклади</h2>
-
-<h3 id="Визначення_сетерів_на_нових_обєктах_у_обєктних_ініціалізаторах">Визначення сетерів на нових об'єктах у об'єктних ініціалізаторах</h3>
-
-<p>Наступний код визначає псевдовластивість <code>current</code> об'єкта <code>language</code>. Коли <code>current</code> присвоюється значення, це змінює <code>log</code> на таке саме значення:</p>
-
-<pre class="brush: js notranslate">const language = {
- set current(name) {
- this.log.push(name);
- },
-  log: []
-}
-
-language.current = 'EN';
-console.log(language.log); // ['EN']
-
-language.current = 'UA';
-console.log(language.log); // ['EN', 'UA']
-</pre>
-
-<p>Зверніть увагу, що  властивість <code>current</code> не визначена, і будь-які спроби звернутись до неї повернуть значення <code>undefined</code>.</p>
-
-<h3 id="Видалення_сетера_оператором_delete">Видалення сетера оператором <code>delete</code></h3>
-
-<p>Якщо вам потрібно прибрати сетер, ви можете його просто {{jsxref("Operators/delete", "видалити")}}:</p>
-
-<pre class="brush: js notranslate">delete o.current;
-</pre>
-
-<h3 id="Визначення_сетера_на_існуючому_обєкті_за_допомогою_defineProperty">Визначення сетера на існуючому об'єкті за допомогою <code>defineProperty</code></h3>
-
-<p>Щоб додати сетер до <em>існуючого</em> об'єкта, використовуйте {{jsxref("Object.defineProperty()")}}.</p>
-
-<pre class="brush: js notranslate">const o = {a: 0};
-
-Object.defineProperty(o, 'b', {
- set: function(x) { this.a = x / 2; }
-});
-
-o.b = 10;
-// Запускає сетер, який присвоює 10 / 2 (5) властивості 'a'
-
-console.log(o.a)
-// 5</pre>
-
-<h3 id="Використання_обчислюваного_імені_властивості">Використання обчислюваного імені властивості</h3>
-
-<pre class="brush: js notranslate">const expr = 'foo';
-
-const obj = {
- baz: 'bar',
- set [expr](v) { this.baz = v; }
-};
-
-console.log(obj.baz);
-// "bar"
-
-obj.foo = 'baz';
-// запустити сетер
-
-console.log(obj.baz);
-// "baz"
-</pre>
-
-<h2 id="Специфікації">Специфікації</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Специфікація</th>
- </tr>
- <tr>
- <td>{{SpecName('ESDraft', '#sec-method-definitions', 'Method definitions')}}</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Сумісність_з_веб-переглядачами">Сумісність з веб-переглядачами</h2>
-
-<div class="hidden">
-<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
-</div>
-
-<p>{{Compat("javascript.functions.set")}}</p>
-
-<div id="compat-mobile"></div>
-
-<h2 id="Див._також">Див. також</h2>
-
-<ul>
- <li><a href="/uk/docs/Web/JavaScript/Reference/Functions/get">гетер</a></li>
- <li>{{jsxref("Operators/delete", "delete")}}</li>
- <li>{{jsxref("Object.defineProperty()")}}</li>
- <li>{{jsxref("Object.__defineGetter__", "__defineGetter__")}}</li>
- <li>{{jsxref("Object.__defineSetter__", "__defineSetter__")}}</li>
- <li><a href="/uk/docs/Web/JavaScript/Guide/Working_with_Objects#Визначення_гетерів_та_сетерів">Визначення гетерів та сетерів</a> у посібнику JavaScript</li>
-</ul>