From c5ce5578fc9c3c0ecc06dbd83ee0d7e6329c759c Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Tue, 23 Apr 2019 11:51:28 +0300 Subject: [PATCH] Fix name of JavaScript --- 1-js/01-getting-started/1-intro/article.md | 4 ++-- .../03-closure/article.md | 4 ++-- .../05-global-object/article.md | 2 +- .../04-prototype-methods/article.md | 4 ++-- 1-js/09-classes/01-class/article.md | 2 +- .../article.md | 8 ++++---- 1-js/11-async/07-microtask-queue/article.md | 4 ++-- 1-js/11-async/08-async-await/article.md | 2 +- .../01-pseudo-random-generator/task.md | 2 +- .../1-generators/article.md | 2 +- .../2-async-iterators-generators/article.md | 4 ++-- 1-js/13-modules/01-modules-intro/article.md | 10 +++++----- 1-js/13-modules/02-import-export/article.md | 2 +- .../10-clock-setinterval/task.md | 2 +- .../01-onload-ondomcontentloaded/article.md | 2 +- .../02-script-async-defer/article.md | 2 +- 2-ui/5-loading/03-onload-onerror/article.md | 2 +- .../03-cross-window-communication/article.md | 2 +- .../01-arraybuffer-binary-arrays/article.md | 6 +++--- 4-binary/02-text-decoder/article.md | 2 +- 4-binary/03-blob/article.md | 6 +++--- 4-binary/index.md | 2 +- 5-network/03-fetch-abort/article.md | 2 +- 5-network/04-fetch-crossorigin/article.md | 20 +++++++++---------- 5-network/07-xmlhttprequest/article.md | 4 ++-- 5-network/08-websocket/article.md | 4 ++-- 6-data-storage/01-cookie/article.md | 4 ++-- .../03-regexp-character-classes/article.md | 2 +- .../3-find-html-comments/solution.md | 2 +- .../article.md | 2 +- .../21-regexp-unicode-properties/article.md | 2 +- .../22-regexp-sticky/article.md | 4 ++-- 32 files changed, 61 insertions(+), 61 deletions(-) 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 `
` there. Peopl - + ...
@@ -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. ![](xhr-another-domain.png) @@ -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 `
` to send messages and a `
` for incoming messages:
``` -Javascript is also simple. We open a socket, then on form submission -- `socket.send(message)`, on incoming message -- append it to `div#messages`: +JavaScript is also simple. We open a socket, then on form submission -- `socket.send(message)`, on incoming message -- append it to `div#messages`: ```js let socket = new WebSocket("wss://javascript.info/article/websocket/chat/ws"); diff --git a/6-data-storage/01-cookie/article.md b/6-data-storage/01-cookie/article.md index ee16cb36..32abcc73 100644 --- a/6-data-storage/01-cookie/article.md +++ b/6-data-storage/01-cookie/article.md @@ -253,13 +253,13 @@ But we surely can use `samesite` together with other protection measures, like x ## httpOnly -This option has nothing to do with Javascript, but we have to mention it for completeness. +This option has nothing to do with JavaScript, but we have to mention it for completeness. The web-server uses `Set-Cookie` header to set a cookie. And it may set the `httpOnly` option. This option forbids any JavaScript access to the cookie. We can't see such cookie or manipulate it using `document.cookie`. -That's used as a precaution measure, to protect from certain attacks when a hacker injects his own Javascript code into a page and waits for a user to visit that page. That shouldn't be possible at all, a hacker should not be able to inject their code into our site, but there may be bugs that let hackers do it. +That's used as a precaution measure, to protect from certain attacks when a hacker injects his own JavaScript code into a page and waits for a user to visit that page. That shouldn't be possible at all, a hacker should not be able to inject their code into our site, but there may be bugs that let hackers do it. Normally, if such thing happens, and a user visits a web-page with hacker's code, then that code executes and gains access to `document.cookie` with user cookies containing authentication information. That's bad. diff --git a/9-regular-expressions/03-regexp-character-classes/article.md b/9-regular-expressions/03-regexp-character-classes/article.md index 9b4aa0a3..c1bc1bad 100644 --- a/9-regular-expressions/03-regexp-character-classes/article.md +++ b/9-regular-expressions/03-regexp-character-classes/article.md @@ -255,7 +255,7 @@ There exist following character classes: ...But that's not all! -Modern Javascript also allows to look for characters by their Unicode properties, for instance: +Modern JavaScript also allows to look for characters by their Unicode properties, for instance: - A cyrillic letter is: `pattern:\p{Script=Cyrillic}` or `pattern:\p{sc=Cyrillic}`. - A dash (be it a small hyphen `-` or a long dash `—`): `pattern:\p{Dash_Punctuation}` or `pattern:\p{pd}`. diff --git a/9-regular-expressions/08-regexp-greedy-and-lazy/3-find-html-comments/solution.md b/9-regular-expressions/08-regexp-greedy-and-lazy/3-find-html-comments/solution.md index b36eec4a..c066f3e3 100644 --- a/9-regular-expressions/08-regexp-greedy-and-lazy/3-find-html-comments/solution.md +++ b/9-regular-expressions/08-regexp-greedy-and-lazy/3-find-html-comments/solution.md @@ -2,7 +2,7 @@ We need to find the beginning of the comment `match:` -- the lazy quantifier makes the dot stop right before `match:-->`. -But a dot in Javascript means "any symbol except the newline". So multiline comments won't be found. +But a dot in JavaScript means "any symbol except the newline". So multiline comments won't be found. We can use `pattern:[\s\S]` instead of the dot to match "anything": diff --git a/9-regular-expressions/15-regexp-infinite-backtracking-problem/article.md b/9-regular-expressions/15-regexp-infinite-backtracking-problem/article.md index a1e6b507..54bbccd9 100644 --- a/9-regular-expressions/15-regexp-infinite-backtracking-problem/article.md +++ b/9-regular-expressions/15-regexp-infinite-backtracking-problem/article.md @@ -8,7 +8,7 @@ The typical situation -- a regular expression works fine sometimes, but for cert In a web-browser it kills the page. Not a good thing for sure. -For server-side Javascript it may become a vulnerability, and it uses regular expressions to process user data. Bad input will make the process hang, causing denial of service. The author personally saw and reported such vulnerabilities even for very well-known and widely used programs. +For server-side JavaScript it may become a vulnerability, and it uses regular expressions to process user data. Bad input will make the process hang, causing denial of service. The author personally saw and reported such vulnerabilities even for very well-known and widely used programs. So the problem is definitely worth to deal with. diff --git a/9-regular-expressions/21-regexp-unicode-properties/article.md b/9-regular-expressions/21-regexp-unicode-properties/article.md index eb79d5d2..eac9bfbc 100644 --- a/9-regular-expressions/21-regexp-unicode-properties/article.md +++ b/9-regular-expressions/21-regexp-unicode-properties/article.md @@ -1,7 +1,7 @@ # Unicode character properies \p -[Unicode](https://en.wikipedia.org/wiki/Unicode), the encoding format used by Javascript strings, has a lot of properties for different characters (or, technically, code points). They describe which "categories" character belongs to, and a variety of technical details. +[Unicode](https://en.wikipedia.org/wiki/Unicode), the encoding format used by JavaScript strings, has a lot of properties for different characters (or, technically, code points). They describe which "categories" character belongs to, and a variety of technical details. In regular expressions these can be set by `\p{…}`. And there must be flag `'u'`. diff --git a/9-regular-expressions/22-regexp-sticky/article.md b/9-regular-expressions/22-regexp-sticky/article.md index e79a7987..5a790bb3 100644 --- a/9-regular-expressions/22-regexp-sticky/article.md +++ b/9-regular-expressions/22-regexp-sticky/article.md @@ -5,7 +5,7 @@ To grasp the use case of `y` flag, and see how great it is, let's explore a prac One of common tasks for regexps is "parsing": when we get a text and analyze it for logical components, build a structure. -For instance, there are HTML parsers for browser pages, that turn text into a structured document. There are parsers for programming languages, like Javascript, etc. +For instance, there are HTML parsers for browser pages, that turn text into a structured document. There are parsers for programming languages, like JavaScript, etc. Writing parsers is a special area, with its own tools and algorithms, so we don't go deep in there, but there's a very common question: "What is the text at the given position?". @@ -15,7 +15,7 @@ For instance, for a programming language variants can be like: - Or an operator `pattern:[+-/*]`? - (a syntax error if it's not anything in the expected list) -In Javascript, to perform a search starting from a given position, we can use `regexp.exec` with `regexp.lastIndex` property, but that's not what we need! +In JavaScript, to perform a search starting from a given position, we can use `regexp.exec` with `regexp.lastIndex` property, but that's not what we need! We'd like to check the match exactly at given position, not "starting" from it.