From 95aca4b4d8fa62815d4bd412fff1a364f842814a Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Thu, 29 Apr 2021 16:16:42 -0700 Subject: remove retired locales (#699) --- .../reference/statements/const/index.html | 232 --------------------- 1 file changed, 232 deletions(-) delete mode 100644 files/uk/web/javascript/reference/statements/const/index.html (limited to 'files/uk/web/javascript/reference/statements/const/index.html') diff --git a/files/uk/web/javascript/reference/statements/const/index.html b/files/uk/web/javascript/reference/statements/const/index.html deleted file mode 100644 index 18e898e6cb..0000000000 --- a/files/uk/web/javascript/reference/statements/const/index.html +++ /dev/null @@ -1,232 +0,0 @@ ---- -title: const -slug: Web/JavaScript/Reference/Statements/const -tags: - - константа -translation_of: Web/JavaScript/Reference/Statements/const ---- -
{{jsSidebar("Statements")}}
- -

Оголошення const створює посилання на значення, доступне лише для читання. Що не гарантує незмінність значення, на котре вказує посилання, а лише той факт, що не можна повторно присвоїти будь-яке значення змінній з відповідним ім'ям.

- -

Синтаксис

- -
const назваКонстантноїЗмінної1 = значення1 [, назваКонстантноїЗмінної2 = значення2 [, ... [, назваКонстантноїЗмінноїN = значенняN]]];
- -
-
значенняN
-
Назва константи, будь-який прийнятний {{Glossary("identifier")}} (ідентифікатор).
-
значенняN
-
Значення константи; будь-яки дозволений вираз (expression).
-
- -

Description

- -

This declaration creates a constant that can be either global or local to the function in which it is declared. An initializer for a constant is required; that is, you must specify its value in the same statement in which it's declared (which makes sense, given that it can't be changed later).

- -

Constants are block-scoped, much like variables defined using the let statement. The value of a constant cannot change through re-assignment, and it can't be redeclared.

- -

All the considerations about the "temporal dead zone" that apply to let, also apply to const.

- -

A constant cannot share its name with a function or a variable in the same scope.

- -

Examples

- -

The following example demonstrates how constants behave. Try this in your browser console.

- -
// NOTE: Constants can be declared with uppercase or lowercase, but a common
-// convention is to use all-uppercase letters.
-
-// define MY_FAV as a constant and give it the value 7
-const MY_FAV = 7;
-
-// this will throw an error in Firefox and Chrome (but does not fail in Safari)
-MY_FAV = 20;
-
-// will print 7
-console.log("my favorite number is: " + MY_FAV);
-
-// trying to redeclare a constant throws an error
-const MY_FAV = 20;
-
-// the name MY_FAV is reserved for constant above, so this will also fail
-var MY_FAV = 20;
-
-// this throws an error also
-let MY_FAV = 20;
-
-// it's important to note the nature of block scoping
-if (MY_FAV === 7) {
-    // this is fine and creates a block scoped MY_FAV variable
-    // (works equally well with let to declare a block scoped non const variable)
-    const MY_FAV = 20;
-
-    // MY_FAV is now 20
-    console.log("my favorite number is " + MY_FAV);
-
-    // this gets hoisted into the global context and throws an error
-    var MY_FAV = 20;
-}
-
-// MY_FAV is still 7
-console.log("my favorite number is " + MY_FAV);
-
-// Assigning to A const variable is a syntax error
-const A = 1; A = 2;
-
-// throws an error, missing initializer in const declaration
-const FOO;
-
-// const also works on objects
-const MY_OBJECT = {"key": "value"};
-
-// Overwriting the object behaves as above (throws an error in Firefox and Chrome but does not fail in Safari)
-MY_OBJECT = {"OTHER_KEY": "value"};
-
-// However, object keys are not protected,
-// so the following statement is executed without problem
-MY_OBJECT.key = "otherValue"; // Use Object.freeze() to make object immutable
-
- -

Specifications

- - - - - - - - - - - - - - - - - - - -
SpecificationStatusComment
{{SpecName('ES6', '#sec-let-and-const-declarations', 'Let and Const Declarations')}}{{Spec2('ES6')}}Initial definition.
{{SpecName('ESDraft', '#sec-let-and-const-declarations', 'Let and Const Declarations')}}{{Spec2('ESDraft')}} 
- -

Browser compatibility

- -

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{CompatChrome(21)}}{{CompatVersionUnknown}}{{CompatGeckoDesktop(36)}}11125.1
Reassignment fails{{CompatChrome(20)}}{{CompatVersionUnknown}}{{CompatGeckoDesktop(13)}}11{{CompatUnknown}}{{CompatUnknown}}
Allowed in sloppy mode{{CompatChrome(49.0)}}     
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
Basic support{{CompatNo}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}
Reassignment fails{{CompatNo}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}
Allowed in sloppy mode{{CompatNo}}{{CompatChrome(49.0)}}    {{CompatChrome(49.0)}}
-
- -

Compatibility notes

- -

In earlier versions of Firefox & Chrome and as of Safari 5.1.7 and Opera 12.00, if you define a variable with const, you can still change its value later. It is not supported in Internet Explorer 6-10, but is included in Internet Explorer 11.

- -

Firefox-specific notes

- -

The const declaration was implemented in Firefox long before const appeared in the ECMAScript 2015 (ES6) specification. For const ES6 compliance see {{bug(950547)}} and {{bug(611388)}}.

- - - -

See also

- - -- cgit v1.2.3-54-g00ecf