Skip to content

Commit e4e2ec9

Browse files
committed
Do some grammatic cleanup
1 parent d573b46 commit e4e2ec9

File tree

12 files changed

+47
-51
lines changed

12 files changed

+47
-51
lines changed

doc/arrayctor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ which it avoids the use of a `for` loop.
2222
### In conclusion
2323

2424
The use of the `Array` constructor should be avoided as much as possible. The `[]`
25-
notation is definitely preferred. It is shorter and has a clear syntax, and is
26-
therefore increasing the readability of code and helps to avoid subtle mistakes.
25+
notation is definitely preferred. It is shorter and has a clearer syntax; thus,
26+
it also increases the readability of code.
2727

doc/closures.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ defined in. Since the only scope that JavaScript has is the
2727

2828
In the above example `Counter` returns **two** closures. The function `increment`
2929
as well as the function `get`. Both of these functions keep a **reference** to
30-
the scope of `Counter` and therefore always have access to the `count` variable
30+
the scope of `Counter` and, therefore, always have access to the `count` variable
3131
that was defined in that **very** scope.
3232

3333
### Why private variables work
@@ -81,8 +81,7 @@ In order to copy the value of the loop its index variable, it is best to use an
8181
}
8282

8383
The anonymous outer function gets called immediately with `i` as the first
84-
argument, therefore it will receive a copy of the **value** of `i` as its
85-
parameter `e`.
84+
argument and will receive a copy of the **value** of `i` as its parameter `e`.
8685

8786
The anonymous function that gets passed to `setTimeout` now has a reference to
8887
`e`, which value does **not** get changed by the loop.

doc/equality.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ The above table shows the results of the type coercion and it is the main reason
2424
why the use of `==` is regarded as bad practice, it introduces hard to track down
2525
bugs due to its complicated conversion rules.
2626

27-
Additionally there is also a performance impact when type coercion is in play,
28-
since for example a string has to be converted to a number before the comparison
29-
is done.
27+
Additionally there is also a performance impact when type coercion is in play;
28+
for example, a string has to be converted to a number before it can be compared
29+
with another number.
3030

3131
### The strict equals operator
3232

doc/forinloop.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Just like the `in` operator, the `for in` loop also traverses the prototype
44
chain when iterating over the properties of an object.
55

66
> **Note:** The `for in` loop will **not** iterate over any properties that
7-
> have their `enumerable` attribute set to `false`, for example the `length`
7+
> have their `enumerable` attribute set to `false`; for example, the `length`
88
> property of an array.
99
1010
// Poisoning Object.prototype
@@ -34,8 +34,8 @@ object.
3434

3535
This version is the only correct one to use. Due to the use of `hasOwnPropery` it
3636
will **only** print out `moo`. When `hasOwnProperty` is left out, the code is
37-
prone to errors when the native prototypes - for example `Object.prototype` -
38-
have been extended.
37+
prone to errors when the native prototypes have been extended; for example,
38+
`Object.prototype`.
3939

4040
One widely used framework which does this is [**Prototype**][1]. When this
4141
framework is included, `for in` loops that doe not use `hasOwnProperty` are

doc/functions.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ passed around like any other value. One common use of this feature is to pass
88

99
function foo() {}
1010

11-
The above function gets created **before** the execution of the program starts.
12-
Therefore it is available everywhere in the scope it was *defined* in, even if it
13-
is called before its actual definition in the source.
11+
The above function gets created **before** the execution of the program starts;
12+
thus, it is available *everywhere* in the scope it was *defined* in, even if
13+
called before the actual definition in the source.
1414

1515
foo(); // Works because foo was created before this code runs
1616
function foo() {}
@@ -19,8 +19,8 @@ is called before its actual definition in the source.
1919

2020
var foo = function() {};
2121

22-
The above assigns the unnamed and therefore *anonymous* function, to the variable
23-
`foo`.
22+
The above assigns the unnamed and, therefore, *anonymous* function, to the
23+
variable `foo`.
2424

2525
foo; // 'undefined'
2626
foo(); // this raises a TypeError
@@ -72,7 +72,7 @@ Also, while the statements inside the `if` block never get executed, the variabl
7272

7373
### `var` vs. `function`
7474

75-
All `var` statements get parsed **before** `function` statements, therefore
75+
All `var` statements get parsed **before** `function` statements; hence,
7676
subsequent statements will override the previous ones.
7777

7878
function foo() {}

doc/instanceof.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ returns a mess similar to the [typeof operator](#typeof).
2121
'foo' instanceof Object; // false
2222

2323
One important thing to note is that `instanceof` does of course not work on
24-
objects that origin from different JavaScript contexts. For example: Different
24+
objects that origin from different JavaScript contexts;rFor example, different
2525
documents in a web browser.
26-
a Web Browser.
2726

2827
### In conclusion
2928

doc/objects.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ the use of property names that would otherwise lead to a syntax error.
6666
Object properties can be both notated as plain characters and as strings. Due to
6767
another mis-design in JavaScript's parser, the above raises a `SyntaxError`.
6868

69-
The error is getting raised because `delete` is a *keyword* of the language,
70-
therefore it must be, just like `case`, notated as a string literal.
69+
The error is getting raised because `delete` is a *keyword* of the language;
70+
therefore, it must be notated as a string literal.
7171

7272
### In conclusion
7373

doc/prototype.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ The first major difference is that inheritance in JavaScript is done by using
3636
Bar.method()
3737

3838
The above object `test` will inherit from both `Bar.prototype` and
39-
`Foo.prototype`. It will therefore have access to the function `method` that was
39+
`Foo.prototype`. Hence, it will have access to the function `method` that was
4040
defined on `Foo`, but it will not have access to the **property** `value` of a
4141
`Foo` instance since that property gets defined in the [constructor](#constructor)
4242
of `Foo`. Which, in this case, never gets called.
4343

4444
> **Note:** Do **not** use `Bar.property = Foo`, since it will not point to
45-
> the prototype of `Foo` but rather to the function object `Foo`. Therefore the
46-
> prototype chain will go over `Function.prototype` in this case, which results
47-
> in `method` not being on the prototype chain.
45+
> the prototype of `Foo` but rather to the function object `Foo`. Because of
46+
> that, the prototype chain will go over `Function.prototype`, which results
47+
> in `method` not being on it.
4848
4949
### Property lookup
5050

@@ -86,9 +86,9 @@ chains.
8686
Bar.prototype: [Foo Instance]
8787
Bar.method()
8888

89-
Now `Bar.prototype` points to an *instance* of `Foo`, therefore the property
90-
`value` of **that** instance is now on the prototype chain and since `Foo` itself
91-
has a prototype, the chain continues with that one afterwards.
89+
Now `Bar.prototype` points to an *instance* of `Foo`; thus, the property
90+
`value` of that very instance is now on the prototype chain. And since `Foo`
91+
itself has a prototype, the chain continues with that one afterwards.
9292

9393
### Performance
9494

@@ -110,7 +110,7 @@ is still no good reason for cluttering built in types with additional
110110
non-standard functionality.
111111

112112
The **only** good reason for extending a built in prototype is to back port
113-
the features of newer JavaScript engines to older ones, like for example
113+
the features of newer JavaScript engines to older ones; for example,
114114
[`Array.forEach`][3].
115115

116116
### In conclusion

doc/scopes.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## Scopes and Namespaces
22

33
Although JavaScript deals fine with the block scope syntax of two matching curly
4-
braces, it does **not** support block scope. Therefore all that's left is *function
5-
scope*.
4+
braces, it does **not** support block scope; thus, all that is left is the
5+
*function scope*.
66

77
> **Note:** When not used in an assignment or as a function argument, the `{...}`
88
> notation will get interpreted as a block statement and **not** as an `Object`.
@@ -44,8 +44,6 @@ Leaving out the `var` statement will override the value of `foo`, this might not
4444
seem like a big deal at first, but consider having a ten-thousand line
4545
JavaScript file with lots and lots of different variable names, not using `var`
4646
will introduce hard to track down bugs.
47-
48-
For example, when using generic variable names like `i` in loops.
4947

5048
// global scope
5149
var items = [/* some list */];
@@ -62,8 +60,8 @@ For example, when using generic variable names like `i` in loops.
6260

6361
The outer loop will terminate after the first call to `subLoop` since that
6462
function overwrites the global value of `i`. Using a `var` for the second
65-
`for` loop would have easily avoided this error, therefore `var` should never be
66-
left out unless the desired effect **is** to affect the outer scope.
63+
`for` loop would have easily avoided this error. The `var` statement should never
64+
be left out unless the desired effect **is** to affect the outer scope.
6765

6866
### Local variables
6967

doc/this.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ reference to a variable.
8787
var test = someObject.methodTest();
8888
test();
8989

90-
Again due to the first case, `test` now acts like like a plain function call and
91-
therefore the `this` inside it will no longer refer to `someObject`.
90+
Again due to the first case `test` now acts like like a plain function call;
91+
therefore, `this` inside it will no longer refer to `someObject`.
9292

93-
While the late binding of `this` might seem like a bad thing, it is fact what
93+
While the late binding of `this` might seem like a bad idea, it is in fact what
9494
makes [prototypical inheritance](#prototype) work.
9595

9696
function Foo() {}

doc/timeouts.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ it is necessary to use brute force in order to achieve this functionality.
9494
clearTimeout(i);
9595
}
9696

97-
There might still be timeouts that are unaffected by this arbitrary number, it
98-
is therefore recommended to keep track of all the timeouts and intervals IDs
99-
instead.
97+
There might still be timeouts that are unaffected by this arbitrary number;
98+
therefore, is is instead recommended to keep track of all the timeout IDs, so
99+
they can be cleared one by one.
100100

101-
### Things to avoid at all costs
101+
### Hidden `eval` magic
102102

103103
`setTimeout` and `setInterval` can also take a string as their first parameter.
104104
This feature should **never** be used, since it internally makes use of `eval`.
@@ -116,8 +116,8 @@ This feature should **never** be used, since it internally makes use of `eval`.
116116
bar();
117117

118118
Since `eval` is not getting [called directly](#eval) here, the string passed to
119-
`setTimeout` will get executed in the global scope and will therefore not use
120-
the local `foo` of `bar`.
119+
`setTimeout` will get executed in the global scope; thus, it will not use the
120+
local variable `foo` from the scope of `bar`.
121121

122122
It is further recommended to **not** use a string to pass arguments to the
123123
function that will get called.

doc/typeof.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ you can see this is anything but consistent.
3636

3737
The *Class* refers to the value of the internal `[[Class]]` property of an object.
3838

39-
> **From the Specification:** *Class* can be one of the following values:
40-
> `"Arguments"`, `"Array"`, `"Boolean"`, `"Date"`, `"Error"`, `"Function"`,
41-
> `"JSON"`, `"Math"`, `"Number"`, `"Object"`, `"RegExp"`, `"String"`
39+
> **From the Specification:** The value of `[[Class]]` can be one of the
40+
> following strings. `Arguments`, `Array`, `Boolean`, `Date`, `Error`,
41+
> `Function`, `JSON`, `Math`, `Number`, `Object`, `RegExp`, `String`.
4242
4343
In order to retrieve the value of *Class* one can has to make use of the
4444
`toString` method of `Object`.
@@ -69,10 +69,10 @@ referencing it would result in a `ReferenceError`. This is the only thing
6969
### In conclusion
7070

7171
In order to check the type of an object, it is highly recommended to use
72-
`Object.prototype.toString`, as it is the only reliable way of doing so.
73-
As shown in the type table, some return values of `typeof` are not defined in the
74-
specification and can therefore differ in various implementations.
72+
`Object.prototype.toString`; as this is the only reliable way of doing so.
73+
As shown in the above type table, some return values of `typeof` are not defined
74+
in the specification; thus, the can across various implementations.
7575

76-
Unless checking for a variable to be defined, `typeof` should be avoided at
76+
Unless checking whether a variable is defined, `typeof` should be avoided at
7777
**all costs**.
7878

0 commit comments

Comments
 (0)