diff options
author | Ryan Johnson <rjohnson@mozilla.com> | 2021-04-29 16:16:42 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 16:16:42 -0700 |
commit | 95aca4b4d8fa62815d4bd412fff1a364f842814a (patch) | |
tree | 5e57661720fe9058d5c7db637e764800b50f9060 /files/uk/web/javascript/reference/global_objects/undefined | |
parent | ee3b1c87e3c8e72ca130943eed260ad642246581 (diff) | |
download | translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.tar.gz translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.tar.bz2 translated-content-95aca4b4d8fa62815d4bd412fff1a364f842814a.zip |
remove retired locales (#699)
Diffstat (limited to 'files/uk/web/javascript/reference/global_objects/undefined')
-rw-r--r-- | files/uk/web/javascript/reference/global_objects/undefined/index.html | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/files/uk/web/javascript/reference/global_objects/undefined/index.html b/files/uk/web/javascript/reference/global_objects/undefined/index.html deleted file mode 100644 index 66028e114d..0000000000 --- a/files/uk/web/javascript/reference/global_objects/undefined/index.html +++ /dev/null @@ -1,140 +0,0 @@ ---- -title: undefined -slug: Web/JavaScript/Reference/Global_Objects/undefined -tags: - - JavaScript - - Проста величина -translation_of: Web/JavaScript/Reference/Global_Objects/undefined ---- -<div>{{jsSidebar("Objects")}}</div> - -<p><span class="seoSummary">Глобальна властивість <code><strong>undefined</strong></code> представляє просте значення <code>{{Glossary("Undefined", "undefined")}}</code>. Це один з {{Glossary("Primitive", "простих типів")}} JavaScript.</span></p> - -<p>{{js_property_attributes(0,0,0)}}</p> - -<p>{{EmbedInteractiveExample("pages/js/globalprops-undefined.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"><code>undefined</code></pre> - -<h2 id="Опис">Опис</h2> - -<p><code>undefined</code> is a property of the <em>global object</em>; i.e., it is a variable in global scope. The initial value of <code>undefined</code> is the primitive value <code>{{Glossary("Undefined", "undefined")}}</code>.</p> - -<p>In modern browsers (JavaScript 1.8.5 / Firefox 4+), <code>undefined</code> is a non-configurable, non-writable property per the ECMAScript 5 specification. Even when this is not the case, avoid overriding it.</p> - -<p>A variable that has not been assigned a value is of type undefined. A method or statement also returns <code>undefined</code> if the variable that is being evaluated does not have an assigned value. A function returns <code>undefined</code> if a value was not {{jsxref("Statements/return", "returned")}}.</p> - -<div class="warning"> -<p>While it is possible to use it as an {{Glossary("Identifier", "identifier")}} (variable name) in any scope other than the global scope (because <code>undefined</code> is not a {{jsxref("Reserved_Words", "reserved word")}}), doing so is a very bad idea that will make your code difficult to maintain and debug.</p> - -<pre class="brush: js">//DON'T DO THIS - -// logs "foo string" -(function() { var undefined = 'foo'; console.log(undefined, typeof undefined); })(); - -// logs "foo string" -(function(undefined) { console.log(undefined, typeof undefined); })('foo'); -</pre> -</div> - -<h2 id="Приклади">Приклади</h2> - -<h3 id="Сувора_рівність_та_undefined">Сувора рівність та <code>undefined</code></h3> - -<p>Виконавши строге порівняння змінної із значенням <code>undefined</code> можна перевірити, чи змінна має значення. У прикладі нижче змінна <code>x</code> не ініціалізована, тому умовний оператор<code>if</code> буде оцінено як істина (true)</p> - -<pre class="brush: js">var x; -if (x === undefined) { - // код у цьому блоці буде виконано -} -else { - // код у цьому блоку не буде виконано -} -</pre> - -<div class="note"> -<p>Note: The strict equality operator rather than the standard equality operator must be used here, because <code>x == undefined</code> also checks whether <code>x</code> is <code>null</code>, while strict equality doesn't. <code>null</code> is not equivalent to <code>undefined</code>. See {{jsxref("Operators/Comparison_Operators", "comparison operators")}} for details.</p> -</div> - -<h3 id="Typeof_operator_and_undefined"><code>Typeof</code> operator and <code>undefined</code></h3> - -<p>Alternatively, {{jsxref("Operators/typeof", "typeof")}} can be used:</p> - -<pre class="brush: js">var x; -if (typeof x === 'undefined') { - // these statements execute -} -</pre> - -<p>One reason to use {{jsxref("Operators/typeof", "typeof")}} is that it does not throw an error if the variable has not been declared.</p> - -<pre class="brush: js">// x has not been declared before -if (typeof x === 'undefined') { // evaluates to true without errors - // these statements execute -} - -if (x === undefined) { // throws a ReferenceError - -} -</pre> - -<p>However, this kind of technique should be avoided. JavaScript is a statically scoped language, so knowing if a variable is declared can be read by seeing whether it is declared in an enclosing context. The only exception is the global scope, but the global scope is bound to the global object, so checking the existence of a variable in the global context can be done by checking the existence of a property on the <em>global object</em> (using the {{jsxref("Operators/in", "in")}} operator, for instance).</p> - -<h3 id="Void_operator_and_undefined"><code>Void</code> operator and <code>undefined</code></h3> - -<p>The {{jsxref("Operators/void", "void")}} operator is a third alternative.</p> - -<pre class="brush: js">var x; -if (x === void 0) { - // these statements execute -} - -// y has not been declared before -if (y === void 0) { - // throws a - Uncaught ReferenceError: y is not defined -} -</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', '#sec-4.3.9', 'undefined')}}</td> - <td>{{Spec2('ES1')}}</td> - <td>Первинне визначення. Реалізовано у JavaScript 1.3.</td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-15.1.1.3', 'undefined')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-undefined', 'undefined')}}</td> - <td>{{Spec2('ES6')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-undefined', 'undefined')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td></td> - </tr> - </tbody> -</table> - -<h2 id="Підтримка_веб-переглядачами">Підтримка веб-переглядачами</h2> - -<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.builtins.undefined")}}</p> |