From 843e5f32b1b1bbd2b4a7e7194704e07d2dbf9d44 Mon Sep 17 00:00:00 2001 From: evazorro Date: Thu, 18 Oct 2018 11:22:48 -0400 Subject: [PATCH 01/37] Grammatical and wording updates --- 1-js/02-first-steps/01-hello-world/article.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/1-js/02-first-steps/01-hello-world/article.md b/1-js/02-first-steps/01-hello-world/article.md index 2cb3c65e..7e84e733 100644 --- a/1-js/02-first-steps/01-hello-world/article.md +++ b/1-js/02-first-steps/01-hello-world/article.md @@ -47,10 +47,10 @@ The ` ``` - This trick isn't used in modern JavaScript. These comments were used to hide the JavaScript code from old browsers that didn't know about a ` From 8c31fae9fa4c518e87af2cc78bea1354e00054de Mon Sep 17 00:00:00 2001 From: evazorro Date: Thu, 18 Oct 2018 11:27:08 -0400 Subject: [PATCH 02/37] Make "parental permissions" prompt sound more natural --- 1-js/02-first-steps/14-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/14-function-basics/article.md b/1-js/02-first-steps/14-function-basics/article.md index 9f405128..5987569c 100644 --- a/1-js/02-first-steps/14-function-basics/article.md +++ b/1-js/02-first-steps/14-function-basics/article.md @@ -263,7 +263,7 @@ function checkAge(age) { */!* } else { *!* - return confirm('Got a permission from the parents?'); + return confirm('Do you have permission from your parents?'); */!* } } From e06b51996ab9aa5002716cba60666d6302f6ad9f Mon Sep 17 00:00:00 2001 From: evazorro Date: Thu, 18 Oct 2018 11:41:34 -0400 Subject: [PATCH 03/37] Reword "clue" sentence This sounds more natural and professional --- 1-js/02-first-steps/14-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/14-function-basics/article.md b/1-js/02-first-steps/14-function-basics/article.md index 5987569c..e301d776 100644 --- a/1-js/02-first-steps/14-function-basics/article.md +++ b/1-js/02-first-steps/14-function-basics/article.md @@ -334,7 +334,7 @@ So, it effectively becomes an empty return. We should put the value on the same ## Naming a function [#function-naming] -Functions are actions. So their name is usually a verb. It should briefly, but as accurately as possible describe what the function does. So that a person who reads the code gets the right clue. +Functions are actions. So their name is usually a verb. It should briefly, but as accurately as possible, describe what the function does, so that someone reading the code gets an indication of what the function does. It is a widespread practice to start a function with a verbal prefix which vaguely describes the action. There must be an agreement within the team on the meaning of the prefixes. From 1ffbae42fa13cac5554fa85e8e15f2b1c6219c97 Mon Sep 17 00:00:00 2001 From: evazorro Date: Thu, 18 Oct 2018 12:24:28 -0400 Subject: [PATCH 04/37] Update question with more natural phrasing --- .../15-function-expressions-arrows/article.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/1-js/02-first-steps/15-function-expressions-arrows/article.md b/1-js/02-first-steps/15-function-expressions-arrows/article.md index 201a1ffe..e6380bd2 100644 --- a/1-js/02-first-steps/15-function-expressions-arrows/article.md +++ b/1-js/02-first-steps/15-function-expressions-arrows/article.md @@ -78,8 +78,8 @@ let func = sayHi; Everything would work the same. Even more obvious what's going on, right? -````smart header="Why there's a semicolon at the end?" -There might be a question, why does Function Expression have a semicolon `;` at the end, and Function Declaration does not: +````smart header="Why is there a semicolon at the end?" +You might wonder, why does Function Expression have a semicolon `;` at the end, but Function Declaration does not: ```js function sayHi() { @@ -198,7 +198,7 @@ The more subtle difference is *when* a function is created by the JavaScript eng **A Function Expression is created when the execution reaches it and is usable from then on.** -Once the execution flow passes to the right side of the assignment `let sum = function…` -- here we go, the function is created and can be used (assigned, called etc) from now on. +Once the execution flow passes to the right side of the assignment `let sum = function…` -- here we go, the function is created and can be used (assigned, called, etc. ) from now on. Function Declarations are different. @@ -350,7 +350,7 @@ welcome(); // ok now ``` -```smart header="When to choose Function Declaration versus Function Expression?" +```smart header="When should you choose Function Declaration versus Function Expression?" As a rule of thumb, when we need to declare a function, the first to consider is Function Declaration syntax, the one we used before. It gives more freedom in how to organize our code, because we can call such functions before they are declared. It's also a little bit easier to look up `function f(…) {…}` in the code than `let f = function(…) {…}`. Function Declarations are more "eye-catching". From 6634ecfac39044c2d24a1f305630c845bc4b2d20 Mon Sep 17 00:00:00 2001 From: Jerry Smith Date: Sun, 21 Oct 2018 20:03:34 +0300 Subject: [PATCH 05/37] Fix present simple, remove redundant word --- 2-ui/2-events/04-default-browser-action/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/2-events/04-default-browser-action/article.md b/2-ui/2-events/04-default-browser-action/article.md index 2e338dc5..b2889132 100644 --- a/2-ui/2-events/04-default-browser-action/article.md +++ b/2-ui/2-events/04-default-browser-action/article.md @@ -17,7 +17,7 @@ There are two ways to tell the browser we don't want it to act: - The main way is to use the `event` object. There's a method `event.preventDefault()`. - If the handler is assigned using `on` (not by `addEventListener`), then we can just return `false` from it. -In the example below there a click to links don't lead to URL change: +In the example below a click to links doesn't lead to URL change: ```html autorun height=60 no-beautify Click here From d9cbf258806a83391a7f9d9ce7644ef61a6b6fc2 Mon Sep 17 00:00:00 2001 From: daGo Date: Mon, 22 Oct 2018 14:38:18 +0300 Subject: [PATCH 06/37] fixSentence [-] What's the benefit over using `Symbol("id")` over a string `"id"`? [+] What's the benefit of using `Symbol("id")` over a string `"id"`? --- 1-js/04-object-basics/03-symbol/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/04-object-basics/03-symbol/article.md b/1-js/04-object-basics/03-symbol/article.md index ba398941..b4336762 100644 --- a/1-js/04-object-basics/03-symbol/article.md +++ b/1-js/04-object-basics/03-symbol/article.md @@ -75,7 +75,7 @@ user[id] = "ID Value"; alert( user[id] ); // we can access the data using the symbol as the key ``` -What's the benefit over using `Symbol("id")` over a string `"id"`? +What's the benefit of using `Symbol("id")` over a string `"id"`? Let's make the example a bit deeper to see that. From b7bf483ac8768798248cd6039dabaeb12b0597d7 Mon Sep 17 00:00:00 2001 From: Cat McLoughlin Date: Fri, 19 Oct 2018 16:24:55 -0700 Subject: [PATCH 07/37] Adjust grammar in Coding Style page --- .../02-coding-style/article.md | 118 ++++++++---------- 1 file changed, 54 insertions(+), 64 deletions(-) diff --git a/1-js/03-code-quality/02-coding-style/article.md b/1-js/03-code-quality/02-coding-style/article.md index 3ab32554..accc407c 100644 --- a/1-js/03-code-quality/02-coding-style/article.md +++ b/1-js/03-code-quality/02-coding-style/article.md @@ -1,14 +1,12 @@ -# Coding style +# Coding Style Our code must be as clean and easy to read as possible. -That is actually an art of programming -- to take a complex task and code it in a way that is both correct and human-readable. - -One thing to help is the good code style. +That is actually the art of programming -- to take a complex task and code it in a way that is both correct and human-readable. ## Syntax -A cheatsheet with the rules (more details below): +Here is a cheatsheet with some suggested rules (see below for more details): ![](code-style.png) ![](figure-bracket-style.png) -As a summary: -- For a really short code, one line is acceptable: like `if (cond) return null`. -- But a separate line for each statement in brackets is usually better. +In summary: +- For very short code, one line is acceptable. For example: `if (cond) return null`. +- But a separate line for each statement in brackets is usually easier to read. -### Line length +### Line Length -The maximal line length should be limited. No one likes to eye-follow a long horizontal line. It's better to split it. +No one likes to read a long horizontal line of code. It's best practice to split them up and limit the length of your lines. -The maximal line length is agreed on the team-level. It's usually 80 or 120 characters. +The maximum line length should be agreed upon at the team-level. It's usually 80 or 120 characters. ### Indents There are two types of indents: -- **A horizontal indent: 2(4) spaces.** +- **Horizontal indents: 2 or 4 spaces.** A horizontal indentation is made using either 2 or 4 spaces or the "Tab" symbol. Which one to choose is an old holy war. Spaces are more common nowadays. @@ -107,9 +105,9 @@ There are two types of indents: } ``` -- **A vertical indent: empty lines for splitting code into logical blocks.** +- **Vertical indents: empty lines for splitting code into logical blocks.** - Even a single function can often be divided in logical blocks. In the example below, the initialization of variables, the main loop and returning the result are split vertically: + Even a single function can often be divided into logical blocks. In the example below, the initialization of variables, the main loop and returning the result are split vertically: ```js function pow(x, n) { @@ -125,21 +123,21 @@ There are two types of indents: Insert an extra newline where it helps to make the code more readable. There should not be more than nine lines of code without a vertical indentation. -### A semicolon +### Semicolons -A semicolon should be present after each statement. Even if it could possibly be skipped. +A semicolon should be present after each statement, even if it could possibly be skipped. -There are languages where a semicolon is truly optional. It's rarely used there. But in JavaScript there are few cases when a line break is sometimes not interpreted as a semicolon. That leaves a place for programming errors. +There are languages where a semicolon is truly optional and it is rarely used. In JavaScript, though, there are cases where a line break is not interpreted as a semicolon, leaving the code vulnerable to errors. -As you become more mature as a programmer, you may choose a no-semicolon style, like [StandardJS](https://standardjs.com/), but that's only when you know JavaScript well and understand possible pitfalls. +As you become more mature as a programmer, you may choose a no-semicolon style like [StandardJS](https://standardjs.com/). Until then, it's best to use semicolons to avoid possible pitfalls. -### Nesting levels +### Nesting Levels -There should not be too many nesting levels. +Try to avoid nesting code too many levels deep. -Sometimes it's a good idea to use the ["continue"](info:while-for#continue) directive in the loop to evade extra nesting in `if(..) { ... }`: +Sometimes it's a good idea to use the ["continue"](info:while-for#continue) directive in a loop to avoid extra nesting. -Instead of: +For example, instead of adding a nested `if` conditional like this: ```js for (let i = 0; i < 10; i++) { @@ -162,7 +160,7 @@ A similar thing can be done with `if/else` and `return`. For example, two constructs below are identical. -The first one: +Option 1: ```js function pow(x, n) { @@ -180,7 +178,7 @@ function pow(x, n) { } ``` -And this: +Option 2: ```js function pow(x, n) { @@ -199,13 +197,13 @@ function pow(x, n) { } ``` -...But the second one is more readable, because the "edge case" of `n < 0` is handled early on, and then we have the "main" code flow, without an additional nesting. +The second one is more readable because the "edge case" of `n < 0` is handled early on. Once the check is done we can move on to the "main" code flow without the need for additional nesting. -## Functions below the code +## Function Placement -If you are writing several "helper" functions and the code to use them, then there are three ways to place them. +If you are writing several "helper" functions and the code that uses them, there are three ways to organize the functions. -1. Functions above the code that uses them: +1. Functions declared above the code that uses them: ```js // *!*function declarations*/!* @@ -235,7 +233,6 @@ If you are writing several "helper" functions and the code to use them, then the walkAround(); // --- *!*helper functions*/!* --- - function createElement() { ... } @@ -248,39 +245,37 @@ If you are writing several "helper" functions and the code to use them, then the ... } ``` -3. Mixed: a function is described where it's first used. +3. Mixed: a function is declared where it's first used. Most of time, the second variant is preferred. -That's because when reading a code, we first want to know "what it does". If the code goes first, then it provides that information. And then maybe we won't need to read functions at all, especially if their names are adequate to what they're doing. +That's because when reading code, we first want to know *what it does*. If the code goes first, then it provides that information. Then, maybe we won't need to read the functions at all, especially if their names are descriptive of what they actually do. -## Style guides +## Style Guides -A style guide contains general rules about "how to write": which quotes to use, how many spaces to indent, where to put line breaks, etc. A lot of minor things. +A style guide contains general rules about "how to write" code, e.g. which quotes to use, how many spaces to indent, where to put line breaks, etc. A lot of minor things. -In total, when all members of a team use the same style guide, the code looks uniform. No matter who of the team wrote it, it's still the same style. +When all members of a team use the same style guide the code tends looks uniform, regardless of which team member wrote it. -Surely, a team may think out a style guide themselves. But as of now, there's no need to. There are many tried, worked-out style guides, which are easy to adopt. +Of course, a team can always write their own style guide. Most of the time though, there's no need to. There are many existing tried and true options to choose from, so adopting one of these is usually your best bet. -For instance: +Some popular choices: - [Google JavaScript Style Guide](https://google.github.io/styleguide/javascriptguide.xml) - [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) - [Idiomatic.JS](https://github.com/rwaldron/idiomatic.js) - [StandardJS](https://standardjs.com/) -- (there are more) +- (plus many more) -If you're a novice developer, then you could start with the cheatsheet above in the chapter, and later browse the style guides to pick up the common principles and maybe choose one. +If you're a novice developer, start with the cheatsheet at the beginning of this chapter. Once you've mastered that you can browse other style guides to pick up common principles and decide which one you like best. -## Automated linters +## Automated Linters -There are tools that can check the code style automatically. They are called "linters". +Linters are tools that can automatically check the style of your code and make suggestions for refactoring. -The great thing about them is that style-checking also finds some bugs, like a typo in a variable or function name. +The great thing about them is that style-checking can also find some bugs, like typos in variable or function names. Because of this feature, installing a linter is recommended even if you don't want to stick to one particular "code style". -So it's recommended to install one, even if you don't want to stick to a "code style". They help to find typos -- and that's already good enough. - -Most well-known tools are: +Here are the most well-known linting tools: - [JSLint](http://www.jslint.com/) -- one of the first linters. - [JSHint](http://www.jshint.com/) -- more settings than JSLint. @@ -288,15 +283,16 @@ Most well-known tools are: All of them can do the job. The author uses [ESLint](http://eslint.org/). -Most linters are integrated with editors: just enable the plugin in the editor and configure the style. +Most linters are integrated with many popular editors: just enable the plugin in the editor and configure the style. For instance, for ESLint you should do the following: 1. Install [Node.JS](https://nodejs.org/). 2. Install ESLint with the command `npm install -g eslint` (npm is a JavaScript package installer). 3. Create a config file named `.eslintrc` in the root of your JavaScript project (in the folder that contains all your files). +4. Install/enable the plugin for your editor that integrates with ESLint. The majority of editors have one. -Here's an example of `.eslintrc`: +Here's an example of an `.eslintrc` file: ```js { @@ -313,22 +309,16 @@ Here's an example of `.eslintrc`: } ``` -Here the directive `"extends"` denotes that we base on the "eslint:recommended" set of settings, and then we specify our own. +Here the directive `"extends"` denotes that the configuration is based on the "eslint:recommended" set of settings. After that, we specify our own. -Then install/enable the plugin for your editor that integrates with ESLint. The majority of editors have it. +It is also possible to download style rule sets from the web and extend them instead. See for more details about installation. -It is possible to download style rule sets from the web and extend them instead. See for more details about installation. - -Using a linter has a great side-effect: linters catch typos. For instance, when an undefined variable is accessed, a linter detects it and (if integrated with an editor) highlights it. In most cases that's a mistype. So we can fix it right ahead. - -For that reason even if you're not concerned about styles, using a linter is highly recommended. - -Also certain IDEs support built-in linting, that also may be good, but not so tunable as ESLint. +Also certain IDEs have built-in linting, which is convenient but not as customizable as ESLint. ## Summary -All syntax rules from this chapter and the style guides aim to increase readability, so all of them are debatable. +All syntax rules described in this chapter (and in the style guides referenced) aim to increase the readability of your code, but all of them are debatable. -When we think about "how to write better?", the sole criterion is "what makes the code more readable and easier to understand? what helps to avoid errors?" That's the main thing to keep in mind when choosing the style or discussing which one is better. +When we think about writing "better" code, the questions we should ask are, "What makes the code more readable and easier to understand?" and "What can help us avoid errors?" These are the main things to keep in mind when choosing and debating code styles. -Read style guides to see the latest ideas about that and follow those that you find the best. +Reading popular style guides will allow you to keep up to date with the latest ideas about code style trends and best practices. From 547aead30496c432222bedbe91de791716557b1f Mon Sep 17 00:00:00 2001 From: Khai Nguyen Date: Mon, 22 Oct 2018 16:21:43 -0700 Subject: [PATCH 08/37] Update article.md --- .../01-primitives-methods/article.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/1-js/05-data-types/01-primitives-methods/article.md b/1-js/05-data-types/01-primitives-methods/article.md index 4d40cd5d..a40fdf55 100644 --- a/1-js/05-data-types/01-primitives-methods/article.md +++ b/1-js/05-data-types/01-primitives-methods/article.md @@ -1,19 +1,22 @@ # Methods of primitives -JavaScript allows us to work with primitives (strings, numbers etc) as if they were objects. +JavaScript allows us to work with primitives (strings, numbers, etc.) as if they were objects. -They also provide methods to call as such. We will study those soon, but first we'll see how it works, because, of course, primitives are not objects (and here we will make it even more clear). +They also provide methods to call as such. We will study those soon, but first we'll see how it works because, of course, primitives are not objects (and here we will make it even clearer). -Let's look at the key distinction between primitives and objects. +Let's look at the key distinctions between primitives and objects. A primitive -: Is a value of a primitive type. There are 6 primitive types: `string`, `number`, `boolean`, `symbol`, `null` and `undefined`. + +- Is a value of a primitive type. +- There are 6 primitive types: `string`, `number`, `boolean`, `symbol`, `null` and `undefined`. An object -: Is capable of storing multiple values as properties. -Can be created with `{}`, for instance: `{name: "John", age: 30}`. There are other kinds of objects in JavaScript, e.g. functions are objects. -One of the best things about objects is that we can store a function as one of its properties: +- Is capable of storing multiple values as properties. +- Can be created with `{}`, for instance: `{name: "John", age: 30}`. There are other kinds of objects in JavaScript; functions, for example, are objects. + +One of the best things about objects is that we can store a function as one of its properties. ```js run let john = { @@ -28,7 +31,7 @@ john.sayHi(); // Hi buddy! So here we've made an object `john` with the method `sayHi`. -Many built-in objects already exist, such as those that work with dates, errors, HTML elements etc. They have different properties and methods. +Many built-in objects already exist, such as those that work with dates, errors, HTML elements, etc. They have different properties and methods. But, these features come with a cost! From afe292b1535c014e8b490c33628a27508bc683dc Mon Sep 17 00:00:00 2001 From: Christian Reed Date: Tue, 23 Oct 2018 13:05:47 -0700 Subject: [PATCH 09/37] "Can" instead of "Can't" I think that's what the author meant. --- 1-js/05-data-types/02-number/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/05-data-types/02-number/article.md b/1-js/05-data-types/02-number/article.md index b42e9f1e..2a5a371e 100644 --- a/1-js/05-data-types/02-number/article.md +++ b/1-js/05-data-types/02-number/article.md @@ -349,7 +349,7 @@ But in real life we often have values in units, like `"100px"` or `"12pt"` in CS That's what `parseInt` and `parseFloat` are for. -They "read" a number from a string until they can. In case of an error, the gathered number is returned. The function `parseInt` returns an integer, whilst `parseFloat` will return a floating-point number: +They "read" a number from a string until they can't. In case of an error, the gathered number is returned. The function `parseInt` returns an integer, whilst `parseFloat` will return a floating-point number: ```js run alert( parseInt('100px') ); // 100 From 6362f48f8d53edf32a2452f2a0174de2107495ce Mon Sep 17 00:00:00 2001 From: loumarven Date: Wed, 24 Oct 2018 23:11:29 +0800 Subject: [PATCH 10/37] Changed "independant" to "independent" --- 1-js/04-object-basics/01-object/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/04-object-basics/01-object/article.md b/1-js/04-object-basics/01-object/article.md index cf161926..eb15654c 100644 --- a/1-js/04-object-basics/01-object/article.md +++ b/1-js/04-object-basics/01-object/article.md @@ -605,7 +605,7 @@ for (let key in user) { } */!* -// now clone is a fully independant clone +// now clone is a fully independent clone clone.name = "Pete"; // changed the data in it alert( user.name ); // still John in the original object From 9a98dddcedebe775ff02fabbd317d5abcf5b1622 Mon Sep 17 00:00:00 2001 From: loumarven Date: Wed, 24 Oct 2018 23:15:11 +0800 Subject: [PATCH 11/37] Improved sentence composition --- 1-js/04-object-basics/01-object/4-const-object/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/04-object-basics/01-object/4-const-object/task.md b/1-js/04-object-basics/01-object/4-const-object/task.md index 95f7a64d..a9aada63 100644 --- a/1-js/04-object-basics/01-object/4-const-object/task.md +++ b/1-js/04-object-basics/01-object/4-const-object/task.md @@ -4,7 +4,7 @@ importance: 5 # Constant objects? -Is it possible to change an object declared with `const`, how do you think? +Is it possible to change an object declared with `const`? What do you think? ```js const user = { From f1bf9d711c5743acc86d5a1b716939cc1857386c Mon Sep 17 00:00:00 2001 From: Arnau Date: Wed, 24 Oct 2018 17:11:12 +0000 Subject: [PATCH 12/37] Update article.md Add comma preceding "etc." uses. --- 1-js/01-getting-started/1-intro/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/01-getting-started/1-intro/article.md b/1-js/01-getting-started/1-intro/article.md index 69bb189a..e9fc6ad1 100644 --- a/1-js/01-getting-started/1-intro/article.md +++ b/1-js/01-getting-started/1-intro/article.md @@ -26,7 +26,7 @@ Different engines have different "codenames", for example: - [V8](https://en.wikipedia.org/wiki/V8_(JavaScript_engine)) -- in Chrome and Opera. - [SpiderMonkey](https://en.wikipedia.org/wiki/SpiderMonkey) -- in Firefox. -- ...There are other codenames like "Trident", "Chakra" for different versions of IE, "ChakraCore" for Microsoft Edge, "Nitro" and "SquirrelFish" for Safari etc. +- ...There are other codenames like "Trident", "Chakra" for different versions of IE, "ChakraCore" for Microsoft Edge, "Nitro" and "SquirrelFish" for Safari, etc. The terms above are good to remember, because they are used in developer articles on the internet. We'll use them too. For instance, if "a feature X is supported by V8", then it probably works in Chrome and Opera. @@ -45,7 +45,7 @@ The engine applies optimizations on every stage of the process. It even watches The 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. -The capabilities greatly depend on the environment that runs JavaScript. For instance, [Node.JS](https://wikipedia.org/wiki/Node.js) supports functions that allow JavaScript to read/write arbitrary files, perform network requests etc. +The capabilities greatly depend on the environment that runs JavaScript. 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. From ee31ef1567aba8e85c141896bf71465ca934ebf6 Mon Sep 17 00:00:00 2001 From: Will Worth Date: Thu, 25 Oct 2018 18:03:05 +0200 Subject: [PATCH 13/37] Update article.md Typo- Singular /plural --- 2-ui/1-document/07-modifying-document/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/1-document/07-modifying-document/article.md b/2-ui/1-document/07-modifying-document/article.md index 90e3f2bb..9c38b334 100644 --- a/2-ui/1-document/07-modifying-document/article.md +++ b/2-ui/1-document/07-modifying-document/article.md @@ -409,7 +409,7 @@ The syntax: The call to `document.write(html)` writes the `html` into page "right here and now". The `html` string can be dynamically generated, so it's kind of flexible. We can use JavaScript to create a full-fledged webpage and write it. -The method comes from times when there were no DOM, no standards... Really old times. It still lives, because there are scripts using it. +The method comes from times when there was no DOM, no standards... Really old times. It still lives, because there are scripts using it. In modern scripts we can rarely see it, because of the following important limitation: From 90ce0219ea7c5d234df8cb681050dd4da27360a1 Mon Sep 17 00:00:00 2001 From: Mathias Bockwoldt Date: Fri, 26 Oct 2018 17:00:58 +0200 Subject: [PATCH 14/37] Added missing semicolon To be consistent, I added a semicolon after a `let` command --- 1-js/04-object-basics/01-object/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/04-object-basics/01-object/article.md b/1-js/04-object-basics/01-object/article.md index cf161926..ea35a026 100644 --- a/1-js/04-object-basics/01-object/article.md +++ b/1-js/04-object-basics/01-object/article.md @@ -205,7 +205,7 @@ let obj = { for: 1, let: 2, return: 3 -} +}; alert( obj.for + obj.let + obj.return ); // 6 ``` From 34bb5ab173d6711eb1a48cd37d670c54aa9eaf25 Mon Sep 17 00:00:00 2001 From: Mario Viens Date: Fri, 26 Oct 2018 15:41:27 -0700 Subject: [PATCH 15/37] Fix typo. --- 6-async/05-async-await/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/6-async/05-async-await/article.md b/6-async/05-async-await/article.md index 23b58240..0a76f1a0 100644 --- a/6-async/05-async-await/article.md +++ b/6-async/05-async-await/article.md @@ -183,7 +183,7 @@ The meaning is the same: it ensures that the returned value is a promise and ena ```` ## Error handling -If a promise resolves normally, then `await promise` returns the result. But in case of a rejection, it throws the error, just if there were a `throw` statement at that line. +If a promise resolves normally, then `await promise` returns the result. But in case of a rejection, it throws the error, just as if there were a `throw` statement at that line. This code: From a5724261b3630b5976474161cd357bf896497eb5 Mon Sep 17 00:00:00 2001 From: Joel V Zachariah Date: Sat, 27 Oct 2018 14:12:41 +0530 Subject: [PATCH 16/37] Removed the braces --- 1-js/01-getting-started/2-code-editors/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/01-getting-started/2-code-editors/article.md b/1-js/01-getting-started/2-code-editors/article.md index 233a0ba2..34b7ab7a 100644 --- a/1-js/01-getting-started/2-code-editors/article.md +++ b/1-js/01-getting-started/2-code-editors/article.md @@ -18,7 +18,7 @@ If you haven't considered selecting an IDE yet, look at the following variants: All of the IDEs except cross-platform. -For Windows, there's also a "Visual Studio" editor, don't mess it with "Visual Studio Code". "Visual Studio" is a paid and actually very powerful Windows-only editor, well-suited for .NET platform. A free version of it is called ([Visual Studio Community](https://www.visualstudio.com/vs/community/)). +For Windows, there's also a "Visual Studio" editor, don't mess it with "Visual Studio Code". "Visual Studio" is a paid and actually very powerful Windows-only editor, well-suited for .NET platform. A free version of it is called [Visual Studio Community](https://www.visualstudio.com/vs/community/). Many IDEs are paid, but have a trial period. Their cost is usually negligible compared to a qualified developer's salary, so just choose the best one for you. From 55d1a1e8e8d749e5ba7ff355594cb85876fd24d0 Mon Sep 17 00:00:00 2001 From: Jerry Smith Date: Sat, 27 Oct 2018 21:06:27 +0300 Subject: [PATCH 17/37] Fix a typo --- 2-ui/2-events/05-dispatch-events/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/2-events/05-dispatch-events/article.md b/2-ui/2-events/05-dispatch-events/article.md index f6ac9f22..8b37edae 100644 --- a/2-ui/2-events/05-dispatch-events/article.md +++ b/2-ui/2-events/05-dispatch-events/article.md @@ -269,7 +269,7 @@ To generate an event, we first need to create an event object. The generic `Event(name, options)` constructor accepts an arbitrary event name and the `options` object with two properties: - `bubbles: true` if the event should bubble. - - `cancelable: true` is the `event.preventDefault()` should work. + - `cancelable: true` if the `event.preventDefault()` should work. Other constructors of native events like `MouseEvent`, `KeyboardEvent` and so on accept properties specific to that event type. For instance, `clientX` for mouse events. From be572bdb4c9f0be356afeaa8a4f3cd0e24db73b2 Mon Sep 17 00:00:00 2001 From: daGo Date: Sun, 28 Oct 2018 10:33:10 +0300 Subject: [PATCH 18/37] add the quotes now they do the same --- 1-js/04-object-basics/04-object-methods/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/04-object-basics/04-object-methods/article.md b/1-js/04-object-basics/04-object-methods/article.md index a93869ed..35055cc5 100644 --- a/1-js/04-object-basics/04-object-methods/article.md +++ b/1-js/04-object-basics/04-object-methods/article.md @@ -316,7 +316,7 @@ When parentheses `()` are called on the Reference Type, they receive the full in Any other operation like assignment `hi = user.hi` discards the reference type as a whole, takes the value of `user.hi` (a function) and passes it on. So any further operation "loses" `this`. -So, as the result, the value of `this` is only passed the right way if the function is called directly using a dot `obj.method()` or square brackets `obj[method]()` syntax (they do the same here). Later in this tutorial, we will learn various ways to solve this problem such as [func.bind()](/bind#solution-2-bind). +So, as the result, the value of `this` is only passed the right way if the function is called directly using a dot `obj.method()` or square brackets `obj['method']()` syntax (they do the same here). Later in this tutorial, we will learn various ways to solve this problem such as [func.bind()](/bind#solution-2-bind). ## Arrow functions have no "this" From 37761062b4c88ca0ac822ca63a461620d54c5345 Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 15:56:23 +0300 Subject: [PATCH 19/37] min is not defined! Should be: mins --- .../09-class/1-rewrite-to-class/source.view/clock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/07-object-oriented-programming/09-class/1-rewrite-to-class/source.view/clock.js b/1-js/07-object-oriented-programming/09-class/1-rewrite-to-class/source.view/clock.js index b1a26250..d312c93e 100644 --- a/1-js/07-object-oriented-programming/09-class/1-rewrite-to-class/source.view/clock.js +++ b/1-js/07-object-oriented-programming/09-class/1-rewrite-to-class/source.view/clock.js @@ -11,7 +11,7 @@ Clock.prototype._render = function() { if (hours < 10) hours = '0' + hours; let mins = date.getMinutes(); - if (mins < 10) min = '0' + mins; + if (mins < 10) mins = '0' + mins; let secs = date.getSeconds(); if (secs < 10) secs = '0' + secs; From 6b3b4850384423075219dde7b80a2fdafd914794 Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 15:57:26 +0300 Subject: [PATCH 20/37] Min is not defined Should be: mins --- .../09-class/1-rewrite-to-class/solution.view/clock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/07-object-oriented-programming/09-class/1-rewrite-to-class/solution.view/clock.js b/1-js/07-object-oriented-programming/09-class/1-rewrite-to-class/solution.view/clock.js index c710b9da..8009273e 100644 --- a/1-js/07-object-oriented-programming/09-class/1-rewrite-to-class/solution.view/clock.js +++ b/1-js/07-object-oriented-programming/09-class/1-rewrite-to-class/solution.view/clock.js @@ -10,7 +10,7 @@ class Clock { if (hours < 10) hours = '0' + hours; let mins = date.getMinutes(); - if (mins < 10) min = '0' + mins; + if (mins < 10) mins = '0' + mins; let secs = date.getSeconds(); if (secs < 10) secs = '0' + secs; From 3601ec366bc4b60c2b5af6ea66e580e0141ecceb Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 15:58:47 +0300 Subject: [PATCH 21/37] Min is not defined Should be: mins --- .../2-clock-class-extended/solution.view/clock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/07-object-oriented-programming/10-class-inheritance/2-clock-class-extended/solution.view/clock.js b/1-js/07-object-oriented-programming/10-class-inheritance/2-clock-class-extended/solution.view/clock.js index c710b9da..8009273e 100644 --- a/1-js/07-object-oriented-programming/10-class-inheritance/2-clock-class-extended/solution.view/clock.js +++ b/1-js/07-object-oriented-programming/10-class-inheritance/2-clock-class-extended/solution.view/clock.js @@ -10,7 +10,7 @@ class Clock { if (hours < 10) hours = '0' + hours; let mins = date.getMinutes(); - if (mins < 10) min = '0' + mins; + if (mins < 10) mins = '0' + mins; let secs = date.getSeconds(); if (secs < 10) secs = '0' + secs; From 6b0bdac4c027c2e0e6c33e101c5ab266ad3f73b4 Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 15:59:27 +0300 Subject: [PATCH 22/37] Min is not defined Should be: mins --- .../2-clock-class-extended/source.view/clock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/07-object-oriented-programming/10-class-inheritance/2-clock-class-extended/source.view/clock.js b/1-js/07-object-oriented-programming/10-class-inheritance/2-clock-class-extended/source.view/clock.js index c710b9da..8009273e 100644 --- a/1-js/07-object-oriented-programming/10-class-inheritance/2-clock-class-extended/source.view/clock.js +++ b/1-js/07-object-oriented-programming/10-class-inheritance/2-clock-class-extended/source.view/clock.js @@ -10,7 +10,7 @@ class Clock { if (hours < 10) hours = '0' + hours; let mins = date.getMinutes(); - if (mins < 10) min = '0' + mins; + if (mins < 10) mins = '0' + mins; let secs = date.getSeconds(); if (secs < 10) secs = '0' + secs; From 78dc85424a7d0db58bcac1555e7d824a77269021 Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 16:01:01 +0300 Subject: [PATCH 23/37] Min is not defined Should be: mins --- .../2-rewrite-to-prototypes/solution.view/clock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/07-object-oriented-programming/08-class-patterns/2-rewrite-to-prototypes/solution.view/clock.js b/1-js/07-object-oriented-programming/08-class-patterns/2-rewrite-to-prototypes/solution.view/clock.js index 7a193b79..c0363448 100644 --- a/1-js/07-object-oriented-programming/08-class-patterns/2-rewrite-to-prototypes/solution.view/clock.js +++ b/1-js/07-object-oriented-programming/08-class-patterns/2-rewrite-to-prototypes/solution.view/clock.js @@ -9,7 +9,7 @@ Clock.prototype._render = function() { if (hours < 10) hours = '0' + hours; let mins = date.getMinutes(); - if (mins < 10) min = '0' + mins; + if (mins < 10) mins = '0' + mins; let secs = date.getSeconds(); if (secs < 10) secs = '0' + secs; From 8aecaa8598434edff2040adec8e1b2c85888697c Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 16:01:29 +0300 Subject: [PATCH 24/37] Min is not defined Should be: mins --- .../2-rewrite-to-prototypes/source.view/clock.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/07-object-oriented-programming/08-class-patterns/2-rewrite-to-prototypes/source.view/clock.js b/1-js/07-object-oriented-programming/08-class-patterns/2-rewrite-to-prototypes/source.view/clock.js index 26081a35..c4bfaa0f 100644 --- a/1-js/07-object-oriented-programming/08-class-patterns/2-rewrite-to-prototypes/source.view/clock.js +++ b/1-js/07-object-oriented-programming/08-class-patterns/2-rewrite-to-prototypes/source.view/clock.js @@ -9,7 +9,7 @@ function Clock({ template }) { if (hours < 10) hours = '0' + hours; let mins = date.getMinutes(); - if (mins < 10) min = '0' + mins; + if (mins < 10) mins = '0' + mins; let secs = date.getSeconds(); if (secs < 10) secs = '0' + secs; From 1d45b45c079066bcb3e7e7712081d088a44eb3ef Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 16:13:33 +0300 Subject: [PATCH 25/37] =?UTF-8?q?A=20spelling=20mistake=20in=20the=20word?= =?UTF-8?q?=20"preferrably"=E2=9D=97=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There must be one character "r". --- 1-js/08-error-handling/1-try-catch/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/08-error-handling/1-try-catch/article.md b/1-js/08-error-handling/1-try-catch/article.md index eabfb742..ac3e0031 100644 --- a/1-js/08-error-handling/1-try-catch/article.md +++ b/1-js/08-error-handling/1-try-catch/article.md @@ -255,7 +255,7 @@ The syntax is: throw ``` -Technically, we can use anything as an error object. That may be even a primitive, like a number or a string, but it's better to use objects, preferrably with `name` and `message` properties (to stay somewhat compatible with built-in errors). +Technically, we can use anything as an error object. That may be even a primitive, like a number or a string, but it's better to use objects, preferably with `name` and `message` properties (to stay somewhat compatible with built-in errors). JavaScript has many built-in constructors for standard errors: `Error`, `SyntaxError`, `ReferenceError`, `TypeError` and others. We can use them to create error objects as well. From e4be3724a47c46ca5dfa4c19f5565f02c3bb9e24 Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 16:34:19 +0300 Subject: [PATCH 26/37] `Sticky` too MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "The offsetParent is the nearest ancestor that is: 1. CSS-positioned (position is absolute, relative, fixed…❗️or sticky❗️ --- 2-ui/1-document/09-size-and-scroll/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/1-document/09-size-and-scroll/article.md b/2-ui/1-document/09-size-and-scroll/article.md index 7b2adb25..da02abdc 100644 --- a/2-ui/1-document/09-size-and-scroll/article.md +++ b/2-ui/1-document/09-size-and-scroll/article.md @@ -60,7 +60,7 @@ These properties are rarely needed, but still they are the "most outer" geometry The `offsetParent` is the nearest ancestor that is: -1. CSS-positioned (`position` is `absolute`, `relative` or `fixed`), +1. CSS-positioned (`position` is `absolute`, `relative`, `fixed` or `sticky`), 2. or ``, ``, ``, 2. or ``. From e92f02a3954a02f69c7314b653aed02e9eb4eed0 Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 16:43:47 +0300 Subject: [PATCH 27/37] excess semicolon excess semicolon after the 'destroy' method --- .../2-hoverintent/solution.view/hoverIntent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/solution.view/hoverIntent.js b/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/solution.view/hoverIntent.js index a78c7c55..4e6e2a3e 100644 --- a/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/solution.view/hoverIntent.js +++ b/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/solution.view/hoverIntent.js @@ -101,6 +101,6 @@ class HoverIntent { elem.removeEventListener('mousemove', this.onMouseMove); elem.removeEventListener('mouseover', this.onMouseOver); elem.removeEventListener('mouseout', this.onMouseOut); - }; + } } From eb74db5425def5a758552de6e4542426ada1497d Mon Sep 17 00:00:00 2001 From: Prokhor Date: Sun, 28 Oct 2018 16:44:41 +0300 Subject: [PATCH 28/37] excess semicolon excess semicolon after the 'destroy' method --- .../2-hoverintent/source.view/hoverIntent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/source.view/hoverIntent.js b/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/source.view/hoverIntent.js index 29198d8e..caca940b 100644 --- a/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/source.view/hoverIntent.js +++ b/2-ui/3-event-details/3-mousemove-mouseover-mouseout-mouseenter-mouseleave/2-hoverintent/source.view/hoverIntent.js @@ -45,6 +45,6 @@ class HoverIntent { destroy() { /* your code to "disable" the functionality, remove all handlers */ - }; + } } From 14b27426db1bade5e84dc1993f7cd4d91c9c0b0e Mon Sep 17 00:00:00 2001 From: Mrchazaaa Date: Sun, 28 Oct 2018 14:38:32 +0000 Subject: [PATCH 29/37] placed a semicolon after this function expression --- 1-js/02-first-steps/15-function-expressions-arrows/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-expressions-arrows/article.md b/1-js/02-first-steps/15-function-expressions-arrows/article.md index 201a1ffe..b90ed2ef 100644 --- a/1-js/02-first-steps/15-function-expressions-arrows/article.md +++ b/1-js/02-first-steps/15-function-expressions-arrows/article.md @@ -375,7 +375,7 @@ In other words, it's roughly the same as: ```js let func = function(arg1, arg2, ...argN) { return expression; -} +}; ``` ...But much more concise. From f488185658d7d3afce5d298a1f2a1a1757e994e3 Mon Sep 17 00:00:00 2001 From: Prokhor Date: Mon, 29 Oct 2018 02:59:28 +0300 Subject: [PATCH 30/37] misspelling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The page can be divided into four parts: 1. … 2. … 3. … 4. … 5. ??? --- 1-js/03-code-quality/05-testing-mocha/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/03-code-quality/05-testing-mocha/article.md b/1-js/03-code-quality/05-testing-mocha/article.md index 311a0528..02287077 100644 --- a/1-js/03-code-quality/05-testing-mocha/article.md +++ b/1-js/03-code-quality/05-testing-mocha/article.md @@ -96,7 +96,7 @@ The full HTML page with these frameworks and `pow` spec: ```html src="index.html" ``` -The page can be divided into four parts: +The page can be divided into five parts: 1. The `` -- add third-party libraries and styles for tests. 2. The `