Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
iliakan committed Aug 9, 2017
2 parents a69e9e7 + 259f1b9 commit e43e1a0
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion 1-js/01-getting-started/1-intro/article.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# An introduction to JavaScript
# An Introduction to JavaScript

Let's see what's so special about JavaScript, what we can achieve with it and which other technologies play well with it.

Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/07-operators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Funny code, isn't it? We should understand how it works, because sometimes we ca

## Remainder %

The remainder operator `%` despite it's look does not have a relation to percents.
The remainder operator `%` despite its look does not have a relation to percents.

The result of `a % b` is the remainder of the integer division of `a` by `b`.

Expand Down Expand Up @@ -415,7 +415,7 @@ let a = (1+2, 3+4);
alert( a ); // 7 (the result of 3+4)
```
Here, the first expression `1+2` is evaluated, and it's result is thrown away, then `3+4` is evaluated and returned as the result.
Here, the first expression `1+2` is evaluated, and its result is thrown away, then `3+4` is evaluated and returned as the result.
```smart header="Comma has a very low precedence"
Please note that the comma operator has very low precedence, lower than `=`, so parentheses are important in the example above.
Expand Down
3 changes: 2 additions & 1 deletion 1-js/02-first-steps/13-switch/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@ switch (arg) {
case '0':
case '1':
alert( 'One or zero' );
break;
case '2':
alert( 'Two' );
break;
case 3:
alert( 'Never executes!' );
break;
default:
alert( 'An unknown value' )
}
Expand Down
2 changes: 1 addition & 1 deletion 1-js/04-object-basics/04-object-methods/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ The result of a property access `user.hi` is not a function, but a value of Refe

When parentheses `()` are called on the Reference Type, they receive the full information about the object and it's method, and can set the right `this` (`=user` in this case).

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 "looses" `this`.
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).

Expand Down
4 changes: 2 additions & 2 deletions 1-js/04-object-basics/05-object-toprimitive/article.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Object to primitive conversion

What happens when objects are added `obj1 + obj2`, substracted `obj1 - obj2` or printed using `alert(obj)`?
What happens when objects are added `obj1 + obj2`, subtracted `obj1 - obj2` or printed using `alert(obj)`?

There are special methods in objects that do the conversion.

Expand All @@ -11,7 +11,7 @@ In the chapter <info:type-conversions> we've seen the rules for numeric, string

For objects, there's no to-boolean conversion, because all objects are `true` in a boolean context. So there are only string and numeric conversions.

The numeric conversion happens when we substract objects or apply mathematical functions. For instance, `Date` objects (to be covered in the chapter <info:date>) can be substracted, and the result of `date1 - date2` is the time difference between two dates.
The numeric conversion happens when we subtract objects or apply mathematical functions. For instance, `Date` objects (to be covered in the chapter <info:date>) can be subtracted, and the result of `date1 - date2` is the time difference between two dates.

As for the string conversion -- it usually happens when we output an object like `alert(obj)` and in similar contexts.

Expand Down
8 changes: 4 additions & 4 deletions 1-js/04-object-basics/06-constructor-new/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@ alert( new SmallUser().name ); // John

Usually constructors don't have a `return` statement. Here we mention the special behavior with returning objects mainly for the sake of completeness.

````smart header="Omitting brackets"
By the way, we can omit brackets after `new`, if it has no arguments:
````smart header="Omitting parentheses"
By the way, we can omit parentheses after `new`, if it has no arguments:
```js
let user = new User; // <-- no brackets
let user = new User; // <-- no parentheses
// same as
let user = new User();
```
Omitting brackets here is not considered a "good style", but the syntax is permitted by specification.
Omitting parentheses here is not considered a "good style", but the syntax is permitted by specification.
````

## Methods in constructor
Expand Down
2 changes: 1 addition & 1 deletion 1-js/05-data-types/04-array/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Objects allow to store keyed collections of values. That's fine.

But quite often we find that we need an *ordered collection*, where we have a 1st, a 2nd, a 3rd element and so on. For example, we need that to store a list of something: users, goods, HTML elements etc.

It not convenient to use an object here, because it provides no methods to manage the order of elements. We can’t insert a new property “between” the existing ones. Objects are just not meant for such use.
It is not convenient to use an object here, because it provides no methods to manage the order of elements. We can’t insert a new property “between” the existing ones. Objects are just not meant for such use.

There exists a special data structure named `Array`, to store ordered collections.

Expand Down

0 comments on commit e43e1a0

Please sign in to comment.