diff --git a/1-js/01-getting-started/1-intro/article.md b/1-js/01-getting-started/1-intro/article.md index a611d960..c0ad8cba 100644 --- a/1-js/01-getting-started/1-intro/article.md +++ b/1-js/01-getting-started/1-intro/article.md @@ -45,7 +45,7 @@ The engine applies optimizations at each step of the process. It even watches th Modern JavaScript is a "safe" programming language. It does not provide low-level access to memory or CPU, because it was initially created for browsers which do not require it. -Javascript's capabilities greatly depend on the environment it's running in. For instance, [Node.JS](https://wikipedia.org/wiki/Node.js) supports functions that allow JavaScript to read/write arbitrary files, perform network requests, etc. +JavaScript's capabilities greatly depend on the environment it's running in. For instance, [Node.JS](https://wikipedia.org/wiki/Node.js) supports functions that allow JavaScript to read/write arbitrary files, perform network requests, etc. In-browser JavaScript can do everything related to webpage manipulation, interaction with the user, and the webserver. @@ -88,7 +88,7 @@ There are at least *three* great things about JavaScript: + Simple things are done simply. + Support by all major browsers and enabled by default. ``` -Javascript is the only browser technology that combines these three things. +JavaScript is the only browser technology that combines these three things. That's what makes JavaScript unique. That's why it's the most widespread tool for creating browser interfaces. diff --git a/1-js/06-advanced-functions/03-closure/article.md b/1-js/06-advanced-functions/03-closure/article.md index ac0e44c6..465ba311 100644 --- a/1-js/06-advanced-functions/03-closure/article.md +++ b/1-js/06-advanced-functions/03-closure/article.md @@ -221,7 +221,7 @@ function sayHiBye(firstName, lastName) { } ``` -Here the *nested* function `getFullName()` is made for convenience. It can access the outer variables and so can return the full name. Nested functions are quite common in Javascript. +Here the *nested* function `getFullName()` is made for convenience. It can access the outer variables and so can return the full name. Nested functions are quite common in JavaScript. What's much more interesting, a nested function can be returned: either as a property of a new object (if the outer function creates an object with methods) or as a result by itself. It can then be used somewhere else. No matter where, it still has access to the same outer variables. @@ -473,7 +473,7 @@ The code outside of the block (or inside another script) doesn't see variables i ### IIFE -In the past, there were no block-level lexical environment in Javascript. +In the past, there were no block-level lexical environment in JavaScript. So programmers had to invent something. And what they did is called "immediately-invoked function expressions" (abbreviated as IIFE). diff --git a/1-js/06-advanced-functions/05-global-object/article.md b/1-js/06-advanced-functions/05-global-object/article.md index 4d480a03..dee3d769 100644 --- a/1-js/06-advanced-functions/05-global-object/article.md +++ b/1-js/06-advanced-functions/05-global-object/article.md @@ -79,7 +79,7 @@ No, it's not, because it may lead to naming conflicts: the same variable name ca As of now, the multi-purpose `window` is considered a design mistake in the language. -Luckily, there's a "road out of hell", called "Javascript modules". +Luckily, there's a "road out of hell", called "JavaScript modules". If we set `type="module"` attribute on a ``, or ``. ``` diff --git a/2-ui/5-loading/02-script-async-defer/article.md b/2-ui/5-loading/02-script-async-defer/article.md index a5ce0ac4..f5c3faeb 100644 --- a/2-ui/5-loading/02-script-async-defer/article.md +++ b/2-ui/5-loading/02-script-async-defer/article.md @@ -129,7 +129,7 @@ Async scripts are great when we integrate an independant third-party script into ## Dynamic scripts -We can also create a script dynamically using Javascript: +We can also create a script dynamically using JavaScript: ```js run let script = document.createElement('script'); diff --git a/2-ui/5-loading/03-onload-onerror/article.md b/2-ui/5-loading/03-onload-onerror/article.md index 7ff1d3de..e915dedb 100644 --- a/2-ui/5-loading/03-onload-onerror/article.md +++ b/2-ui/5-loading/03-onload-onerror/article.md @@ -23,7 +23,7 @@ document.head.append(script); ...But how to run the function that is declared inside that script? We need to wait until the script loads, and only then we can call it. ```smart -For our own scripts we could use [Javascript modules](info:modules) here, but they are not widely adopted by third-party libraries. +For our own scripts we could use [JavaScript modules](info:modules) here, but they are not widely adopted by third-party libraries. ``` ### script.onload diff --git a/3-frames-and-windows/03-cross-window-communication/article.md b/3-frames-and-windows/03-cross-window-communication/article.md index b4166e20..53cb3cd6 100644 --- a/3-frames-and-windows/03-cross-window-communication/article.md +++ b/3-frames-and-windows/03-cross-window-communication/article.md @@ -246,7 +246,7 @@ The purpose of the `"sandbox"` attribute is only to *add more* restrictions. It The `postMessage` interface allows windows to talk to each other no matter which origin they are from. -So, it's a way around the "Same Origin" policy. It allows a window from `john-smith.com` to talk to `gmail.com` and exchange information, but only if they both agree and call corresponding Javascript functions. That makes it safe for users. +So, it's a way around the "Same Origin" policy. It allows a window from `john-smith.com` to talk to `gmail.com` and exchange information, but only if they both agree and call corresponding JavaScript functions. That makes it safe for users. The interface has two parts. diff --git a/4-binary/01-arraybuffer-binary-arrays/article.md b/4-binary/01-arraybuffer-binary-arrays/article.md index 5f9dec79..d0bb488d 100644 --- a/4-binary/01-arraybuffer-binary-arrays/article.md +++ b/4-binary/01-arraybuffer-binary-arrays/article.md @@ -2,12 +2,12 @@ In web-development we meet binary data mostly while dealing with files (create, upload, download). Another typical use case is image processing. -That's all possible in Javascript, and binary operations are high-performant. +That's all possible in JavaScript, and binary operations are high-performant. Although, there's a bit of confusion, because there are many classes. To name a few: - `ArrayBuffer`, `Uint8Array`, `DataView`, `Blob`, `File`, etc. -Binary data in Javascript is implemented in a non-standard way, compared to other languages. But when we sort things out, everything becomes fairly simple. +Binary data in JavaScript is implemented in a non-standard way, compared to other languages. But when we sort things out, everything becomes fairly simple. **The basic binary object is `ArrayBuffer` -- a reference to a fixed-length contiguos memory area.** @@ -144,7 +144,7 @@ Here's the list of typed arrays: - `Float32Array`, `Float64Array` -- for signed floating-point numbers of 32 and 64 bits. ```warn header="No `int8` or similar single-valued types" -Please note, despite of the names like `Int8Array`, there's no single-value type like `int`, or `int8` in Javascript. +Please note, despite of the names like `Int8Array`, there's no single-value type like `int`, or `int8` in JavaScript. That's logical, as `Int8Array` is not an array of these individual values, but rather a view on `ArrayBuffer`. ``` diff --git a/4-binary/02-text-decoder/article.md b/4-binary/02-text-decoder/article.md index 709a99d5..9287279e 100644 --- a/4-binary/02-text-decoder/article.md +++ b/4-binary/02-text-decoder/article.md @@ -2,7 +2,7 @@ What if the binary data is actually a string? For instance, we received a file with textual data. -The build-in [TextDecoder](https://encoding.spec.whatwg.org/#interface-textdecoder) object allows to read the value into an an actual Javascript string, given the buffer and the encoding. +The build-in [TextDecoder](https://encoding.spec.whatwg.org/#interface-textdecoder) object allows to read the value into an an actual JavaScript string, given the buffer and the encoding. We first need to create it: ```js diff --git a/4-binary/03-blob/article.md b/4-binary/03-blob/article.md index 0cfdab10..d75973ea 100644 --- a/4-binary/03-blob/article.md +++ b/4-binary/03-blob/article.md @@ -1,6 +1,6 @@ # Blob -`ArrayBuffer` and views are a part of ECMA standard, a part of Javascript. +`ArrayBuffer` and views are a part of ECMA standard, a part of JavaScript. In the browser, there are additional higher-level objects, described in [File API](https://www.w3.org/TR/FileAPI/). @@ -52,7 +52,7 @@ The arguments are similar to `array.slice`, negative numbers are allowed too. ```smart header="Blobs are immutable" We can't change data directly in a blob, but we can slice parts of blobs, create new blobs from them, mix them into a new blob and so on. -This behavior is similar to Javascript strings: we can't change a character in a string, but we can make a new corrected string. +This behavior is similar to JavaScript strings: we can't change a character in a string, but we can make a new corrected string. ``` ## Blob as URL @@ -72,7 +72,7 @@ link.href = URL.createObjectURL(blob); ``` -We can also create a link dynamically in Javascript and simulate a click by `link.click()`, then download starts authomatically. +We can also create a link dynamically in JavaScript and simulate a click by `link.click()`, then download starts authomatically. Here's the similar "on the fly" blob creation and download code, but without HTML: diff --git a/4-binary/index.md b/4-binary/index.md index d3f054ba..2b0c5dc8 100644 --- a/4-binary/index.md +++ b/4-binary/index.md @@ -1,3 +1,3 @@ # Binary data, files -Working with binary data and files in Javascript. +Working with binary data and files in JavaScript. diff --git a/5-network/03-fetch-abort/article.md b/5-network/03-fetch-abort/article.md index 0ee45bd9..3e6f4cb4 100644 --- a/5-network/03-fetch-abort/article.md +++ b/5-network/03-fetch-abort/article.md @@ -1,7 +1,7 @@ # Fetch: Abort -Aborting a `fetch` is a little bit tricky. Remember, `fetch` returns a promise. And Javascript generally has no concept of "aborting" a promise. So how can we cancel a fetch? +Aborting a `fetch` is a little bit tricky. Remember, `fetch` returns a promise. And JavaScript generally has no concept of "aborting" a promise. So how can we cancel a fetch? There's a special built-in object for such purposes: `AbortController`. diff --git a/5-network/04-fetch-crossorigin/article.md b/5-network/04-fetch-crossorigin/article.md index 209fc5fe..e1b669e0 100644 --- a/5-network/04-fetch-crossorigin/article.md +++ b/5-network/04-fetch-crossorigin/article.md @@ -24,7 +24,7 @@ Because cross-origin restrictions protect the internet from evil hackers. Seriously. Let's make a very brief historical digression. -For many years Javascript did not have any special methods to perform network requests. +For many years JavaScript did not have any special methods to perform network requests. **A script from one site could not access the content of another site.** @@ -38,7 +38,7 @@ One way to communicate with another server was to submit a `
@@ -105,7 +105,7 @@ Any other request is considered "non-simple". For instance, a request with `PUT` So, even a very old server should be ready to accept a simple request. -Contrary to that, requests with non-standard headers or e.g. method `DELETE` can't be created this way. For a long time Javascript was unable to do such requests. So an old server may assume that such requests come from a privileged source, "because a webpage is unable to send them". +Contrary to that, requests with non-standard headers or e.g. method `DELETE` can't be created this way. For a long time JavaScript was unable to do such requests. So an old server may assume that such requests come from a privileged source, "because a webpage is unable to send them". When we try to make a non-simple request, the browser sends a special "preflight" request that asks the server -- does it agree to accept such cross-origin requests, or not? @@ -134,7 +134,7 @@ The server can inspect the `Origin` and, if it agrees to accept such a request, The browser plays the role of a trusted mediator here: 1. It ensures that the corrent `Origin` is sent with a cross-domain request. -2. If checks for correct `Access-Control-Allow-Origin` in the response, if it is so, then Javascript access, otherwise forbids with an error. +2. If checks for correct `Access-Control-Allow-Origin` in the response, if it is so, then JavaScript access, otherwise forbids with an error.  @@ -149,7 +149,7 @@ Access-Control-Allow-Origin: https://javascript.info ## Response headers -For cross-origin request, by default Javascript may only access "simple response headers": +For cross-origin request, by default JavaScript may only access "simple response headers": - `Cache-Control` - `Content-Language` @@ -166,7 +166,7 @@ Please note: there's no `Content-Length` header in the list! So, if we're downloading something and would like to track the percentage of progress, then an additional permission is required to access that header (see below). ``` -To grant Javascript access to any other response header, the server must list it in the `Access-Control-Expose-Headers` header. +To grant JavaScript access to any other response header, the server must list it in the `Access-Control-Expose-Headers` header. For example: @@ -283,20 +283,20 @@ The server should not forget to add `Accept-Control-Allow-Origin` to the respons Access-Control-Allow-Origin: https://javascript.info ``` -Now everything's correct. Javascript is able to read the full response. +Now everything's correct. JavaScript is able to read the full response. ## Credentials A cross-origin request by default does not bring any credentials (cookies or HTTP authentication). -That's uncommon for HTTP-requests. Usually, a request to `http://site.com` is accompanied by all cookies from that domain. But cross-domain requests made by Javascript methods are an exception. +That's uncommon for HTTP-requests. Usually, a request to `http://site.com` is accompanied by all cookies from that domain. But cross-domain requests made by JavaScript methods are an exception. For example, `fetch('http://another.com')` does not send any cookies, even those that belong to `another.com` domain. Why? -That's because a request with credentials is much more powerful than an anonymous one. If allowed, it grants Javascript the full power to act and access sensitive information on behalf of a user. +That's because a request with credentials is much more powerful than an anonymous one. If allowed, it grants JavaScript the full power to act and access sensitive information on behalf of a user. Does the server really trust pages from `Origin` that much? A request with credentials needs an additional header to pass through. @@ -348,7 +348,7 @@ So, practical difference is that simple requests are sent right away, with `Orig - `Access-Control-Allow-Origin` to `Origin` - `Access-Control-Allow-Credentials` to `true` -Additionally, if Javascript wants no access non-simple response headers: +Additionally, if JavaScript wants no access non-simple response headers: - `Cache-Control` - `Content-Language` - `Content-Type` diff --git a/5-network/07-xmlhttprequest/article.md b/5-network/07-xmlhttprequest/article.md index eeaf0a8a..bda4bd1b 100644 --- a/5-network/07-xmlhttprequest/article.md +++ b/5-network/07-xmlhttprequest/article.md @@ -211,7 +211,7 @@ Nowadays, `load/error/progress` handlers deprecate it. If in the `open` method the third parameter `async` is set to `false`, the request is made synchronously. -In other words, Javascript execution pauses at `send()` and resumes when the response is received. Somewhat like `alert` or `prompt` commands. +In other words, JavaScript execution pauses at `send()` and resumes when the response is received. Somewhat like `alert` or `prompt` commands. Here's the rewritten example, the 3rd parameter of `open` is `false`: @@ -232,7 +232,7 @@ try { }; ``` -It might look good, but synchronous calls are used rarely, because they block in-page Javascript till the loading is complete. In some browsers it becomes impossible to scroll. If a synchronous call takes too much time, the browser may suggest to close the "hanging" webpage. +It might look good, but synchronous calls are used rarely, because they block in-page JavaScript till the loading is complete. In some browsers it becomes impossible to scroll. If a synchronous call takes too much time, the browser may suggest to close the "hanging" webpage. Many advanced capabilities of `XMLHttpRequest`, like requesting from another domain or specifying a timeout, are unavailable for synchronous requests. Also, as you can see, no progress indication. diff --git a/5-network/08-websocket/article.md b/5-network/08-websocket/article.md index 30bfbd77..79d9ee60 100644 --- a/5-network/08-websocket/article.md +++ b/5-network/08-websocket/article.md @@ -96,7 +96,7 @@ Sec-WebSocket-Version: 13 - `Sec-WebSocket-Version` -- WebSocket protocol version, 13 is the current one. ```smart header="WebSocket handshake can't be emulated" -We can't use `XMLHttpRequest` or `fetch` to make this kind of HTTP-request, because Javascript is not allowed to set these headers. +We can't use `XMLHttpRequest` or `fetch` to make this kind of HTTP-request, because JavaScript is not allowed to set these headers. ``` If the server agrees to switch to WebSocket, it should send code 101 response: @@ -289,7 +289,7 @@ HTML: there's a `