Skip to content

Sync with upstream @ fb4fc33a #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 132 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
a4ba2bb
close #2534 by slightly changing 7-microtask-queue
hamirmahal Mar 26, 2021
a662e1c
typo
joaquinelio Mar 27, 2021
67230aa
code
joaquinelio Mar 28, 2021
32eb2f9
typo
joaquinelio Mar 28, 2021
4820b97
repeated word
joaquinelio Mar 28, 2021
01ebc30
typo
joaquinelio Mar 28, 2021
c06e21f
Few grammatical corrections
VenkataPavan2494 Mar 31, 2021
6d0b314
Fix grammatical error
tamiolaf Apr 1, 2021
c722cda
Update article.md
PhilipKirner Apr 1, 2021
334d4de
pseudo function expression
lumosmind Apr 4, 2021
023ec22
typos
joaquinelio Apr 5, 2021
b896887
Fix comma splice.
m4ttsch Apr 5, 2021
a2c36c9
Fix plural typo line 414
dylan-workhub Apr 9, 2021
6de9d70
typo
joaquinelio Apr 11, 2021
dbae68c
Plunker reminder #1775
joaquinelio Apr 11, 2021
8b7bf10
store vs keeps stored
joaquinelio Apr 12, 2021
9e52cf3
Merge pull request #2578 from joaquinelio/patch-15
iliakan Apr 12, 2021
d8be8b0
Add scrollX/scrollY
iliakan Apr 15, 2021
2b33873
Merge pull request #2577 from joaquinelio/patch-14
iliakan Apr 17, 2021
3d8ab89
Merge pull request #2575 from joaquinelio/patch-13
iliakan Apr 17, 2021
35d1c85
Merge pull request #2573 from dylan-workhub/patch-1
iliakan Apr 17, 2021
adb962b
closes #2572
iliakan Apr 17, 2021
09c3914
Merge pull request #2568 from m4ttsch/patch-1
iliakan Apr 17, 2021
362e9a9
Merge pull request #2566 from joaquinelio/patch-11
iliakan Apr 17, 2021
4742c7b
Merge pull request #2565 from lumosmind/patch-8
iliakan Apr 17, 2021
8c5d3bf
Merge pull request #2562 from PhilipKirner/patch-1
iliakan Apr 17, 2021
4092b7f
Merge pull request #2561 from tamiolaf/patch-1
iliakan Apr 17, 2021
8be1642
Merge pull request #2559 from VenkataPavan2494/patch-1
iliakan Apr 17, 2021
ba0b184
Merge pull request #2558 from joaquinelio/patch-9
iliakan Apr 17, 2021
a18c710
Merge pull request #2557 from joaquinelio/patch-8
iliakan Apr 17, 2021
1b4b347
Merge pull request #2556 from joaquinelio/patch-7
iliakan Apr 17, 2021
4b10919
Merge pull request #2550 from hamirmahal/feat/update-readability-of-7…
iliakan Apr 17, 2021
e8a1cd8
Merge pull request #2552 from joaquinelio/patch-4
iliakan Apr 17, 2021
870a88c
Merge pull request #2554 from joaquinelio/patch-5
iliakan Apr 17, 2021
7d624ef
typo it's
joaquinelio Apr 18, 2021
ffd8e03
typos? easier reading - review pls
joaquinelio Apr 18, 2021
6ab384f
Merge pull request #2584 from joaquinelio/patch-7
iliakan Apr 18, 2021
47b1ca8
Fix grammar and wrong information
Violet-Bora-Lee Apr 21, 2021
0ad314c
fix grammar
Violet-Bora-Lee Apr 22, 2021
62bc619
insert empty line
Violet-Bora-Lee Apr 22, 2021
8292f9c
Update article.md
JackStaples Apr 24, 2021
07b364d
Replace preposition with verb
mikemitchell574 Apr 29, 2021
981e34b
Update article.md
josecervino Apr 30, 2021
252cccf
always strict
joaquinelio May 7, 2021
5f972c8
fix(classes): replace [[FunctionKind]] with [[IsClassConstructor]]
H2rmone May 11, 2021
243a0b1
Merge pull request #2582 from joaquinelio/patch-4
iliakan May 13, 2021
055cab1
Merge pull request #2585 from Violet-Bora-Lee/patch-1
iliakan May 13, 2021
c78b2c9
Merge pull request #2586 from Violet-Bora-Lee/patch-2
iliakan May 13, 2021
10c3bcf
Merge pull request #2588 from Violet-Bora-Lee/patch-3
iliakan May 13, 2021
4f06415
closes #2583
iliakan May 13, 2021
74d14af
minor fixes
iliakan May 13, 2021
57e7d67
Merge pull request #2592 from JackStaples/patch-2
iliakan May 13, 2021
5e9db70
Merge pull request #2593 from mikemitchell574/master
iliakan May 13, 2021
0cbf55d
Merge pull request #2595 from josecervino/patch-1
iliakan May 13, 2021
094b829
Merge pull request #2598 from joaquinelio/patch-7
iliakan May 13, 2021
339535d
Merge pull request #2599 from H2rmone/master
iliakan May 13, 2021
3bf8830
Update article.md
iliakan May 13, 2021
237920b
Update article.md
iliakan May 13, 2021
33f1b11
minor fixes
iliakan May 13, 2021
6ad8930
minor fixes
iliakan May 13, 2021
fafab82
typo
joaquinelio May 15, 2021
4177be3
Merge pull request #2602 from joaquinelio/patch-4
iliakan May 16, 2021
80956ed
closes #2600
iliakan May 16, 2021
11e0890
Fix typo.
odsantos May 16, 2021
89183a0
minor fixes
iliakan May 16, 2021
bad5236
minor fixes
iliakan May 16, 2021
70049c3
minor fixes
iliakan May 16, 2021
859fa9b
minor fixes
iliakan May 16, 2021
fb09afc
minor fixes
iliakan May 16, 2021
f598b72
minor fixes
iliakan May 16, 2021
f841402
minor fixes
iliakan May 16, 2021
18a0394
minor fixes
iliakan May 16, 2021
ac96ede
Remove mentions of :host-context
web-padawan May 17, 2021
ae8248b
minor fixes
iliakan May 17, 2021
d2ae45d
Update article.md
Dorin-David May 20, 2021
ffa79a8
minor fixes
iliakan May 24, 2021
a917f9c
minor fixes
iliakan May 24, 2021
94837c2
minor fixes
iliakan May 24, 2021
3e74537
minor fixes
iliakan May 24, 2021
006343a
minor fixes
iliakan May 24, 2021
df45aed
minor fixes
iliakan May 24, 2021
8871521
minor fixes
iliakan May 24, 2021
1770074
minor fixes
iliakan May 24, 2021
3dbe9d1
minor fixes
iliakan May 24, 2021
2fc7cb2
minor fixes
iliakan May 24, 2021
649a159
minor fixes
iliakan May 24, 2021
62db4bb
minor fixes
iliakan May 24, 2021
3288801
minor fixes
iliakan May 24, 2021
6db4961
minor fixes
iliakan May 24, 2021
4343545
minor fixes
iliakan May 24, 2021
053cc05
minor fixes
iliakan May 24, 2021
842f0e2
minor fixes
iliakan May 24, 2021
70bb265
minor fixes
iliakan May 24, 2021
fc3c071
minor fixes
iliakan May 24, 2021
7a30a00
minor fixes
iliakan May 24, 2021
6cfa8b4
minor fixes
iliakan May 24, 2021
649c758
minor fixes
iliakan May 24, 2021
f2636ee
minor fixes
iliakan May 24, 2021
9ba208f
minor fixes
iliakan May 24, 2021
cf33b67
minor fixes
iliakan May 24, 2021
f8313dc
Update article.md
AhmedElaguab May 28, 2021
88ba2c2
Merge pull request #2 from AhmedElaguab/AhmedElaguab-fix-typo
AhmedElaguab May 28, 2021
4c35f59
"not required" vs "incorrect"
joaquinelio May 29, 2021
c2d5f8e
easier to read
joaquinelio Jun 4, 2021
52cb884
Update article.md
leviding Jun 7, 2021
6a742c4
Update article.md
leviding Jun 8, 2021
581802d
minor fixes
iliakan Jun 9, 2021
68172cc
typo
joaquinelio Jun 10, 2021
0e49461
typpo
joaquinelio Jun 10, 2021
964ba15
function parameters vs arguments
iliakan Jun 13, 2021
1ccd673
Merge pull request #2624 from joaquinelio/patch-11
iliakan Jun 13, 2021
54ff266
Merge pull request #2623 from joaquinelio/patch-9
iliakan Jun 13, 2021
2b1600e
Merge pull request #2622 from leviding/patch-37
iliakan Jun 13, 2021
581117f
Merge pull request #2621 from leviding/patch-36
iliakan Jun 13, 2021
dcf4b5b
closes #2619
iliakan Jun 13, 2021
2290bd6
Merge pull request #2616 from joaquinelio/patch-8
iliakan Jun 13, 2021
bcb47b7
Merge pull request #2612 from joaquinelio/patch-4
iliakan Jun 13, 2021
5f927bd
Merge pull request #2611 from AhmedElaguab/master
iliakan Jun 13, 2021
4d46f12
Merge pull request #2606 from Dorin-David/patch-1
iliakan Jun 13, 2021
e4ac603
Merge pull request #2605 from web-padawan/patch-1
iliakan Jun 13, 2021
ee5853d
Merge pull request #2604 from odsantos/regex-methods
iliakan Jun 13, 2021
bcf2e48
minor fixes
iliakan Jun 13, 2021
225a36f
Merge branch 'master' of github.com:javascript-tutorial/en.javascript…
iliakan Jun 13, 2021
617dfc7
minor fixes
iliakan Jun 13, 2021
e2d1823
minor fixes
iliakan Jun 13, 2021
614e29e
minor fixes
iliakan Jun 13, 2021
a171b0a
fix typo in 1-js/05-data-types/03-string
ZYinMD Jun 13, 2021
e527c61
Merge pull request #2630 from ZYinMD/patch-10
iliakan Jun 13, 2021
b258e8f
minor fixes
iliakan Jun 14, 2021
fb4fc33
minor fixes
iliakan Jun 15, 2021
b33e869
merging all conflicts
iliakan Jun 15, 2021
60ddea1
Resolve conflicts.
odsantos Jun 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 1-js/01-getting-started/1-intro/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Interpretadores diferentes têm "codinomes" diferentes. Por exemplo:

- [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- no Chrome e no Opera.
- [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- no Firefox.
- ...Há outros codinomes como "Chakra" para o IE, "ChakraCore" para Microsoft Edge, "Nitro" e "SquirrelFish" para Safari, etc.
- ...Há outros codinomes como "Chakra" para o IE, "JavaScriptCore", "Nitro" e "SquirrelFish" para Safari, etc.

Os termos acima são bons para lembrar, pois são usados em artigos de desenvolvedores na internet. Vamos usá-los também. Por exemplo, se "um recurso X é suportado pelo V8", então ele provavelmente funciona no Chrome e no Opera.

Expand Down
36 changes: 16 additions & 20 deletions 1-js/02-first-steps/02-structure/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ alert(3 +
+ 2);
```

O código produz `6` porque o Javascript não insere pontos e virgulas aqui. É intuitivamente óbvio que se a linha termina com um sinal de mais `"+"`, então é uma "expressão incompleta", logo o ponto e vírgula não é necessário. E neste caso isso funciona como pretendido.
O código produz `6` porque o Javascript não insere pontos e virgulas aqui. É intuitivamente óbvio que se a linha termina com um sinal de mais `"+"`, então é uma "expressão incompleta", logo o ponto e vírgula aí seria incorreto. E neste caso isso funciona como pretendido.

**Mas há situações em que o JavaScript "falha" em assumir um ponto e vírgula onde ele é realmente necessário.**

Expand All @@ -56,40 +56,36 @@ Erros que ocorrem em tais casos são bastante difíceis de encontrar e corrigir.
Se você está curioso para ver um exemplo concreto de tal erro, verifique este código:

```js run
[1, 2].forEach(alert)
alert("Hello");

[1, 2].forEach(alert);
```

Não há necessidade de pensar sobre o significado dos parênteses `[]` e `forEach` ainda. Nós vamos estudá-los mais tarde. Por enquanto, apenas lembre-se que o resultado do código: mostra `1` e depois` 2`.
Não há necessidade de pensar sobre o significado dos parênteses `[]` e também do `forEach`. Nós vamos estudá-los mais tarde. Por enquanto, apenas lembre-se do resultado da execução do código: ele mostra `Hello`, depois `1`, e depois` 2`.

Agora, vamos adicionar um `alert` antes do código e * não * terminá-lo com um ponto e vírgula:
Agora, vamos remover o ponto e vírgula depois do `alert`:

```js run no-beautify
alert("Haverá um erro")
alert("Hello")

[1, 2].forEach(alert)
[1, 2].forEach(alert);
```

Agora, se nós executarmos o código, apenas o primeiro `alert` é mostrado e então temos um erro!

Mas tudo está bem novamente se adicionarmos um ponto e vírgula após `alert`:
```js run
alert("Tudo bem agora");
A diferença em comparação com o código acima é de apenas um caractere: o ponto e vírgula da primeira linha se foi.

[1, 2].forEach(alert)
```
Se nós executarmos esse código, apenas o primeiro `Hello` é mostrado (e então há um erro, você pode precisar de abrir a consola para o ver). Já não existem mais números.

Agora temos a mensagem "Tudo bem agora" seguida por "1" e "2".
Isso ocorre porque o JavaScript não assume um ponto e vírgula antes dos colchetes `[...]`. Portanto, o código no último exemplo é tratado como uma única instrução.


O erro na variante sem ponto e vírgula ocorre porque o JavaScript não assume um ponto e vírgula antes dos colchetes `[...]`.

Portanto, como o ponto e vírgula não é inserido automaticamente, o código no primeiro exemplo é tratado como uma única instrução. Veja como o mecanismo vê isso:
Veja como o mecanismo vê isso:

```js run no-beautify
alert("Haverá um erro")[1, 2].forEach(alert)
alert("Hello")[1, 2].forEach(alert);
```

Mas devem ser duas declarações separadas, não uma. Tal fusão neste caso é completamente errado, daí o erro. Isso pode acontecer em outras situações.
Parece estranho, não? Tal fusão neste caso é completamente errada. Nós precisamos de colocar um ponto e vírgula depois de `alert` para o código funcionar corretamente.

Isso também pode acontecer em outras situações.
````

Recomendamos colocar ponto e vírgula entre as frases, mesmo que estejam separadas por novas linhas. Esta regra é amplamente adotada pela comunidade. Vamos notar mais uma vez -- *é possível* deixar de fora os pontos e vírgulas na maior parte do tempo. Mas é mais seguro -- especialmente para um iniciante -- usá-los.
Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/05-types/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Os valores numéricos especiais pertencem formalmente ao tipo "número". Claro q

Veremos mais sobre como trabalhar com números no capítulo <info:number>.

## BigInt
## BigInt [#bigint-type]

In JavaScript, the "number" type cannot represent integer values larger than <code>(2<sup>53</sup>-1)</code> (that's `9007199254740991`), or less than <code>-(2<sup>53</sup>-1)</code> for negatives. It's a technical limitation caused by their internal representation.

Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/08-operators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ In school maths, we write that as a<sup>b</sup>.
For instance:

```js run
alert( 2 ** 2 ); // 2² = 4
alert( 2 ** 3 ); // 2³ = 8
alert( 2 ** 2 ); // 2² = 4
alert( 2 ** 3 ); // 2³ = 8
alert( 2 ** 4 ); // 2⁴ = 16
```

Expand Down
55 changes: 34 additions & 21 deletions 1-js/02-first-steps/15-function-basics/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ function showMessage() {
}
```

A palavra-chave `function` vem primeiro, depois vem o *nome da função*, e uma lista de *parâmetros* entre os parêntesis (vazio no exemplo acima) e finalmente o código da função, também chamado de "o corpo da função", entre chaves.
A palavra-chave `function` vem primeiro, depois vem o *nome da função*, e uma lista de *parâmetros* entre os parêntesis (separados por vírgulas, vazia no exemplo acima, veremos exemplos mais tarde) e finalmente o código da função, também chamado de "o corpo da função", entre chaves.

```js
function name(parameters) {
function name(parameter1, parameter2, ... parameterN) {
...corpo...
}
```
Expand Down Expand Up @@ -137,26 +137,23 @@ It's a good practice to minimize the use of global variables. Modern code has fe

## Parameters

We can pass arbitrary data to functions using parameters (also called *function arguments*) .
We can pass arbitrary data to functions using parameters.

In the example below, the function has two parameters: `from` and `text`.

```js run
function showMessage(*!*from, text*/!*) { // arguments: from, text
function showMessage(*!*from, text*/!*) { // parameters: from, text
alert(from + ': ' + text);
}

*!*
showMessage('Ann', 'Hello!'); // Ann: Hello! (*)
showMessage('Ann', "What's up?"); // Ann: What's up? (**)
*/!*
*!*showMessage('Ann', 'Hello!');*/!* // Ann: Hello! (*)
*!*showMessage('Ann', "What's up?");*/!* // Ann: What's up? (**)
```

When the function is called in lines `(*)` and `(**)`, the given values are copied to local variables `from` and `text`. Then the function uses them.

Here's one more example: we have a variable `from` and pass it to the function. Please note: the function changes `from`, but the change is not seen outside, because a function always gets a copy of the value:


```js run
function showMessage(from, text) {

Expand All @@ -175,19 +172,31 @@ showMessage(from, "Hello"); // *Ann*: Hello
alert( from ); // Ann
```

When a value is passed as a function parameter, it's also called an *argument*.

In other words, to put these terms straight:

- A parameter is the variable listed inside the parentheses in the function declaration (it's a declaration time term)
- An argument is the value that is passed to the function when it is called (it's a call time term).

We declare functions listing their parameters, then call them passing arguments.

In the example above, one might say: "the function `sayMessage` is declared with two parameters, then called with two arguments: `from` and `"Hello"`".


## Default values

If a parameter is not provided, then its value becomes `undefined`.
If a function is called, but an argument is not provided, then the corresponding value becomes `undefined`.

For instance, the aforementioned function `showMessage(from, text)` can be called with a single argument:

```js
showMessage("Ann");
```

That's not an error. Such a call would output `"Ann: undefined"`. There's no `text`, so it's assumed that `text === undefined`.
That's not an error. Such a call would output `"*Ann*: undefined"`. As the value for `text` isn't passed, it becomes `undefined`.

If we want to use a "default" `text` in this case, then we can specify it after `=`:
We can specify the so-called "default" (to use if omitted) value for a parameter in the function declaration, using `=`:

```js run
function showMessage(from, *!*text = "no text given"*/!*) {
Expand All @@ -211,19 +220,23 @@ function showMessage(from, text = anotherFunction()) {
```smart header="Evaluation of default parameters"
In JavaScript, a default parameter is evaluated every time the function is called without the respective parameter.

In the example above, `anotherFunction()` is called every time `showMessage()` is called without the `text` parameter.
In the example above, `anotherFunction()` isn't called at all, if the `text` parameter is provided.

On the other hand, it's independently called every time when `text` is missing.
```

### Alternative default parameters

Sometimes it makes sense to set default values for parameters not in the function declaration, but at a later stage, during its execution.
Sometimes it makes sense to assign default values for parameters not in the function declaration, but at a later stage.

To check for an omitted parameter, we can compare it with `undefined`:
We can check if the parameter is passed during the function execution, by comparing it with `undefined`:

```js run
function showMessage(text) {
// ...

*!*
if (text === undefined) {
if (text === undefined) { // if the parameter is missing
text = 'empty message';
}
*/!*
Expand All @@ -234,21 +247,21 @@ function showMessage(text) {
showMessage(); // empty message
```

...Or we could use the `||` operator:
...Or we could use the `??` operator:

```js
// if text parameter is omitted or "" is passed, set it to 'empty'
function showMessage(text) {
// if text is undefined or otherwise falsy, set it to 'empty'
text = text || 'empty';
...
}
```

Modern JavaScript engines support the [nullish coalescing operator](info:nullish-coalescing-operator) `??`, it's better when falsy values, such as `0`, are considered regular:
Modern JavaScript engines support the [nullish coalescing operator](info:nullish-coalescing-operator) `??`, it's better when most falsy values, such as `0`, should be considered "normal":

```js run
// if there's no "count" parameter, show "unknown"
function showCount(count) {
// if count is undefined or null, show "unknown"
alert(count ?? "unknown");
}

Expand Down Expand Up @@ -411,7 +424,7 @@ Functions that are used *very often* sometimes have ultrashort names.

For example, the [jQuery](http://jquery.com) framework defines a function with `$`. The [Lodash](http://lodash.com/) library has its core function named `_`.

These are exceptions. Generally functions names should be concise and descriptive.
These are exceptions. Generally function names should be concise and descriptive.
```

## Functions == Comments
Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/01-debugging-chrome/article.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Depuração de erros no Chrome
# Depuração de erros no navegador

Antes de escrevermos código mais complexo, vamos falar de debugging (depuração de erros).

Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/06-polyfills/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Modern project build systems, such as [webpack](http://webpack.github.io/), prov

New language features may include not only syntax constructs and operators, but also built-in functions.

For example, `Math.trunc(n)` is a function that "cuts off" the decimal part of a number, e.g `Math.trunc(1.23) = 1`.
For example, `Math.trunc(n)` is a function that "cuts off" the decimal part of a number, e.g `Math.trunc(1.23)` returns `1`.

In some (very outdated) JavaScript engines, there's no `Math.trunc`, so such code will fail.

Expand Down
2 changes: 1 addition & 1 deletion 1-js/04-object-basics/04-object-methods/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ user = {
// method shorthand looks better, right?
user = {
*!*
sayHi() { // same as "sayHi: function()"
sayHi() { // same as "sayHi: function(){...}"
*/!*
alert("Hello");
}
Expand Down
9 changes: 5 additions & 4 deletions 1-js/04-object-basics/06-constructor-new/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ Now if we want to create other users, we can call `new User("Ann")`, `new User("

That's the main purpose of constructors -- to implement reusable object creation code.

Let's note once again -- technically, any function can be used as a constructor. That is: any function can be run with `new`, and it will execute the algorithm above. The "capital letter first" is a common agreement, to make it clear that a function is to be run with `new`.
Let's note once again -- technically, any function (except arrow functions, as they don't have `this`) can be used as a constructor. It can be run with `new`, and it will execute the algorithm above. The "capital letter first" is a common agreement, to make it clear that a function is to be run with `new`.

````smart header="new function() { ... }"
If we have many lines of code all about creation of a single complex object, we can wrap them in constructor function, like this:
If we have many lines of code all about creation of a single complex object, we can wrap them in an immediately called constructor function, like this:

```js
let user = new function() {
// create a function and immediately call it with new
let user = new function() {
this.name = "John";
this.isAdmin = false;

Expand All @@ -80,7 +81,7 @@ let user = new function() {
};
```

The constructor can't be called again, because it is not saved anywhere, just created and called. So this trick aims to encapsulate the code that constructs the single object, without future reuse.
This constructor can't be called again, because it is not saved anywhere, just created and called. So this trick aims to encapsulate the code that constructs the single object, without future reuse.
````

## Constructor mode test: new.target
Expand Down
Loading