You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/06-advanced-functions/05-global-object/article.md
+13-13
Original file line number
Diff line number
Diff line change
@@ -57,33 +57,33 @@ alert(window.currentUser.name); // John
57
57
58
58
Acestea fiind spuse, utilizarea variabilelor globale este în general descurajată. Ar trebui să fie cât mai puține variabile globale pe cât posibil. Proiectarea codului în care o funcție primește variabile de "intrare" și produce un anumit "rezultat" este mai clară, mai puțin predispusă la erori și mai ușor de testat decât în cazul în care folosește variabile exterioare sau globale.
59
59
60
-
## Using for polyfills
60
+
## Utilizarea pentru polyfills
61
61
62
-
We use the global object to test for support of modern language features.
62
+
Utilizăm obiectul global pentru a testa suportul caracteristicilor moderne ale limbajului.
63
63
64
-
For instance, test if a built-in `Promise`object exists (it doesn't in really old browsers):
64
+
De exemplu, testăm dacă există un obiect `Promise`încorporat (nu există în browserele foarte vechi):
65
65
```js run
66
66
if (!window.Promise) {
67
67
alert("Your browser is really old!");
68
68
}
69
69
```
70
70
71
-
If there's none (say, we're in an old browser), we can create "polyfills": add functions that are not supported by the environment, but exist in the modern standard.
71
+
Dacă nu există (să spunem că ne aflăm într-un browser vechi), putem crea "polyfills": adăugăm funcții care nu sunt acceptate de mediul respectiv, dar care există în standardul modern.
72
72
73
73
```js run
74
74
if (!window.Promise) {
75
-
window.Promise=...//custom implementation of the modern language feature
75
+
window.Promise=...//implementare personalizată a funcției de limbaj modern
76
76
}
77
77
```
78
78
79
-
## Summary
79
+
## Sumar
80
80
81
-
-The global object holds variables that should be available everywhere.
81
+
-Obiectul global deține variabile care ar trebui să fie disponibile peste tot.
82
82
83
-
That includes JavaScript built-ins, such as `Array`and environment-specific values, such as `window.innerHeight` -- the window height in the browser.
84
-
-The global object has a universal name`globalThis`.
83
+
Aceasta include integrări JavaScript, cum ar fi `Array`și valorile specifice mediului, cum ar fi `window.innerHeight` -- înălțimea ferestrei în browser.
84
+
-Obiectul global are un nume universal `globalThis`.
85
85
86
-
...But more often is referred by "old-school" environment-specific names, such as `window` (browser) and`global` (Node.js).
87
-
-We should store values in the global object only if they're truly global for our project. And keep their number at minimum.
88
-
-In-browser, unless we're using [modules](info:modules), global functions and variables declared with`var`become a property of the global object.
89
-
-To make our code future-proof and easier to understand, we should access properties of the global object directly, as`window.x`.
86
+
...Dar cel mai adesea este menționat prin nume "old-school" specifice mediului, cum ar fi `window` (browser) și`global` (Node.js).
87
+
-Ar trebui să stocăm valori în obiectul global numai dacă acestea sunt cu adevărat globale pentru proiectul nostru. Și să păstrăm numărul lor la minim.
88
+
-În browser, cu excepția cazului în care folosim [module](info:modules), funcțiile și variabilele globale declarate cu`var`devin o proprietate a obiectului global.
89
+
-Pentru a face codul nostru rezistent pe viitor și mai ușor de înțeles, ar trebui să accesăm direct proprietățile obiectului global, ca`window.x`.
0 commit comments