minor fixes

This commit is contained in:
Ilya Kantor 2020-06-01 09:46:43 +03:00
parent 8f2ae7eb20
commit 9cb597e229

View file

@ -80,20 +80,6 @@ let user = 'John'
Technically, all these variants do the same thing. So, it's a matter of personal taste and aesthetics. Technically, all these variants do the same thing. So, it's a matter of personal taste and aesthetics.
````warn header="Declaring twice triggers an error"
A variable should be declared only once.
A repeated declaration of the same variable is an error:
```js run
let message = "This";
// repeated 'let' leads to an error
let message = "That"; // SyntaxError: 'message' has already been declared
```
So, we declare a variable once, and then should refer to it without `let`.
````
````smart header="`var` instead of `let`" ````smart header="`var` instead of `let`"
In older scripts, you may also find another keyword: `var` instead of `let`: In older scripts, you may also find another keyword: `var` instead of `let`:
@ -148,6 +134,20 @@ alert(hello); // Hello world!
alert(message); // Hello world! alert(message); // Hello world!
``` ```
````warn header="Declaring twice triggers an error"
A variable should be declared only once.
A repeated declaration of the same variable is an error:
```js run
let message = "This";
// repeated 'let' leads to an error
let message = "That"; // SyntaxError: 'message' has already been declared
```
So, we declare a variable once, and then should refer to it without `let`.
````
```smart header="Functional languages" ```smart header="Functional languages"
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. 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.