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/08-prototypes/04-prototype-methods/article.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,8 +72,8 @@ Why so?
72
72
That's for historical reasons.
73
73
74
74
- The `"prototype"` property of a constructor function has worked since very ancient times.
75
-
- Later, in the year 2012:`Object.create` appeared in the standard. It gave the ability to create objects with a given prototype, but did not provide the ability to get/set it. So browsers implemented the non-standard `__proto__` accessor that allowed the user to get/set a prototype at any time.
76
-
- Later, in the year 2015:`Object.setPrototypeOf` and `Object.getPrototypeOf` were added to the standard, to perform the same functionality as `__proto__`. As `__proto__` was de-facto implemented everywhere, it was kind-of deprecated and made its way to the Annex B of the standard, that is: optional for non-browser environments.
75
+
- Later, in the year 2012,`Object.create` appeared in the standard. It gave the ability to create objects with a given prototype, but did not provide the ability to get/set it. So browsers implemented the non-standard `__proto__` accessor that allowed the user to get/set a prototype at any time.
76
+
- Later, in the year 2015,`Object.setPrototypeOf` and `Object.getPrototypeOf` were added to the standard, to perform the same functionality as `__proto__`. As `__proto__` was de-facto implemented everywhere, it was kind-of deprecated and made its way to the Annex B of the standard, that is: optional for non-browser environments.
Copy file name to clipboardExpand all lines: 1-js/09-classes/05-extend-natives/article.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ alert(filteredArr); // 10, 50
21
21
alert(filteredArr.isEmpty()); // false
22
22
```
23
23
24
-
Please note a very interesting thing. Built-in methods like `filter`, `map` and others -- return new objects of exactly the inherited type `PowerArray`. Their internal implementation uses object `constructor` property for that.
24
+
Please note a very interesting thing. Built-in methods like `filter`, `map` and others -- return new objects of exactly the inherited type `PowerArray`. Their internal implementation uses the object's`constructor` property for that.
25
25
26
26
In the example above,
27
27
```js
@@ -74,7 +74,7 @@ Built-in objects have their own static methods, for instance `Object.keys`, `Arr
74
74
75
75
As we already know, native classes extend each other. For instance, `Array` extends `Object`.
76
76
77
-
Normally, when one class extends another, both static and non-static methods are inherited. That was thoroughly explained in the chapter[](info:static-properties-methods#statics-and-inheritance).
77
+
Normally, when one class extends another, both static and non-static methods are inherited. That was thoroughly explained in the article[](info:static-properties-methods#statics-and-inheritance).
78
78
79
79
But built-in classes are an exception. They don't inherit statics from each other.
Copy file name to clipboardExpand all lines: 2-ui/1-document/01-browser-environment/article.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Browser environment, specs
2
2
3
-
The JavaScript language was initially created for web browsers. Since then, it has evolved and become a language with many uses and platforms.
3
+
The JavaScript language was initially created for web browsers. Since then it has evolved and become a language with many uses and platforms.
4
4
5
5
A platform may be a browser, or a web-server or another *host*, even a coffee machine. Each of them provides platform-specific functionality. The JavaScript specification calls that a *host environment*.
6
6
@@ -60,14 +60,14 @@ For instance, server-side scripts that download HTML pages and process them can
60
60
```
61
61
62
62
```smart header="CSSOM for styling"
63
-
CSS rules and stylesheets are structured in a different way than HTML. There's a separate specification [CSSOM](https://www.w3.org/TR/cssom-1/) that explains how they are represented as objects, and how to read and write them.
63
+
CSS rules and stylesheets are structured in a different way than HTML. There's a separate specification, [CSS Object Model (CSSOM)](https://www.w3.org/TR/cssom-1/), that explains how they are represented as objects, and how to read and write them.
64
64
65
65
CSSOM is used together with DOM when we modify style rules for the document. In practice though, CSSOM is rarely required, because usually CSS rules are static. We rarely need to add/remove CSS rules from JavaScript, but that's also possible.
66
66
```
67
67
68
-
## BOM (Browser object model)
68
+
## BOM (Browser Object Model)
69
69
70
-
Browser Object Model (BOM) are additional objects provided by the browser (host environment) to work with everything except the document.
70
+
The Browser Object Model (BOM) represents additional objects provided by the browser (host environment) for working with everything except the document.
Copy file name to clipboardExpand all lines: 5-network/05-fetch-crossorigin/article.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ That policy is called "CORS": Cross-Origin Resource Sharing.
22
22
23
23
## Why CORS is needed? A brief history
24
24
25
-
CORS exists protect the internet from evil hackers.
25
+
CORS exists to protect the internet from evil hackers.
26
26
27
27
Seriously. Let's make a very brief historical digression.
28
28
@@ -149,7 +149,7 @@ As you can see, `Origin` header contains exactly the origin (domain/protocol/por
149
149
The server can inspect the `Origin` and, if it agrees to accept such a request, adds a special header `Access-Control-Allow-Origin` to the response. That header should contain the allowed origin (in our case `https://javascript.info`), or a star `*`. Then the response is successful, otherwise an error.
150
150
151
151
The browser plays the role of a trusted mediator here:
152
-
1. It ensures that the corrent`Origin` is sent with a cross-origin request.
152
+
1. It ensures that the correct`Origin` is sent with a cross-origin request.
153
153
2. It checks for permitting `Access-Control-Allow-Origin`in the response, if it exists, then JavaScript is allowed to access the response, otherwise it fails with an error.
154
154
155
155

@@ -203,13 +203,13 @@ With such `Access-Control-Expose-Headers` header, the script is allowed to read
203
203
204
204
We can use any HTTP-method: not just `GET/POST`, but also `PATCH`, `DELETE` and others.
205
205
206
-
Some time ago no one could even assume that a webpage is able to do such requests. So there may exist webservices that treat a non-standard method as a signal: "That's not a browser". They can take it into account when checking access rights.
206
+
Some time ago no one could even imagine that a webpage could make such requests. So there may still exist webservices that treat a non-standard method as a signal: "That's not a browser". They can take it into account when checking access rights.
207
207
208
208
So, to avoid misunderstandings, any "non-simple" request -- that couldn't be done in the old times, the browser does not make such requests right away. Before it sends a preliminary, so-called "preflight" request, asking for permission.
209
209
210
210
A preflight request uses method `OPTIONS`, no body and two headers:
211
211
212
-
- `Access-Control-Request-Method` header has the method of an the non-simple request.
212
+
- `Access-Control-Request-Method` header has the method of the non-simple request.
213
213
- `Access-Control-Request-Headers` header provides a comma-separated list of its non-simple HTTP-headers.
214
214
215
215
If the server agrees to serve the requests, then it should respond with empty body, status 200 and headers:
Now the browser can see that `PATCH` in `Access-Control-Allow-Methods` and `Content-Type,API-Key` are in the list `Access-Control-Allow-Headers`, so it sends out the main request.
276
+
Now the browser can see that `PATCH` is in `Access-Control-Allow-Methods` and `Content-Type,API-Key` are in the list `Access-Control-Allow-Headers`, so it sends out the main request.
277
277
278
278
Besides, the preflight response is cached for time, specified by `Access-Control-Max-Age` header (86400 seconds, one day), so subsequent requests will not cause a preflight. Assuming that they fit the cached allowances, they will be sent directly.
0 commit comments