Skip to content

Commit caded70

Browse files
sync with main
1 parent 539db1f commit caded70

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

1-js/02-first-steps/04-variables/article.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ let message = 'Hello';
6464
```
6565

6666
Some people also define multiple variables in this multiline style:
67+
6768
```js no-beautify
6869
let user = 'John',
6970
age = 25,
@@ -103,6 +104,7 @@ For instance, the variable `message` can be imagined as a box labeled `"message"
103104
We can put any value in the box.
104105
105106
We can also change it as many times as we want:
107+
106108
```js run
107109
let message;
108110
@@ -149,11 +151,11 @@ So, we should declare a variable once and then refer to it without `let`.
149151
````
150152

151153
```smart header="Functional languages"
152-
It's interesting to note that there exist [functional](https://en.wikipedia.org/wiki/Functional_programming) programming languages, like [Scala](http://www.scala-lang.org/) or [Erlang](http://www.erlang.org/) that forbid changing variable values.
154+
It's interesting to note that there exist so-called [pure functional](https://en.wikipedia.org/wiki/Purely_functional_programming) programming languages, such as [Haskell](https://en.wikipedia.org/wiki/Haskell), that forbid changing variable values.
153155
154156
In such languages, once the value is stored "in the box", it's there forever. If we need to store something else, the language forces us to create a new box (declare a new variable). We can't reuse the old one.
155157
156-
Though it may seem a little odd at first sight, these languages are quite capable of serious development. More than that, there are areas like parallel computations where this limitation confers certain benefits. Studying such a language (even if you're not planning to use it soon) is recommended to broaden the mind.
158+
Though it may seem a little odd at first sight, these languages are quite capable of serious development. More than that, there are areas like parallel computations where this limitation confers certain benefits.
157159
```
158160

159161
## Variable naming [#variable-naming]
@@ -192,11 +194,11 @@ let my-name; // hyphens '-' aren't allowed in the name
192194
```
193195

194196
```smart header="Case matters"
195-
Variables named `apple` and `AppLE` are two different variables.
197+
Variables named `apple` and `APPLE` are two different variables.
196198
```
197199

198200
````smart header="Non-Latin letters are allowed, but not recommended"
199-
It is possible to use any language, including cyrillic letters or even hieroglyphs, like this:
201+
It is possible to use any language, including cyrillic letters, Chinese logograms and so on, like this:
200202
201203
```js
202204
let имя = '...';
@@ -260,7 +262,6 @@ myBirthday = '01.01.2001'; // error, can't reassign the constant!
260262
261263
When a programmer is sure that a variable will never change, they can declare it with `const` to guarantee and clearly communicate that fact to everyone.
262264
263-
264265
### Uppercase constants
265266
266267
There is a widespread practice to use constants as aliases for difficult-to-remember values that are known prior to execution.
@@ -291,13 +292,14 @@ When should we use capitals for a constant and when should we name it normally?
291292
Being a "constant" just means that a variable's value never changes. But there are constants that are known prior to execution (like a hexadecimal value for red) and there are constants that are *calculated* in run-time, during the execution, but do not change after their initial assignment.
292293
293294
For instance:
295+
294296
```js
295297
const pageLoadTime = /* time taken by a webpage to load */;
296298
```
297299
298300
The value of `pageLoadTime` is not known prior to the page load, so it's named normally. But it's still a constant because it doesn't change after assignment.
299301
300-
In other words, capital-named constants are only used as aliases for "hard-coded" values.
302+
In other words, capital-named constants are only used as aliases for "hard-coded" values.
301303
302304
## Name things right
303305

0 commit comments

Comments
 (0)