Skip to content

Commit

Permalink
replace
Browse files Browse the repository at this point in the history
  • Loading branch information
iliakan committed Mar 19, 2017
1 parent e2443e8 commit 75e3053
Show file tree
Hide file tree
Showing 73 changed files with 195 additions and 195 deletions.
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/01-hello-world/article.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hello, world!

The tutorial that you're reading is about the core Javascript, that is platform-independant. So you'll be able to learn how to use Node.JS and other things based on that knowledge.
The tutorial that you're reading is about the core JavaScript, that is platform-independant. So you'll be able to learn how to use Node.JS and other things based on that knowledge.

But we need a working environment to run our scripts, and, just because this book is online, the browser is probably a good choice. We'll use a few browser-specific commands like `alert`, but will keep their amount to the minimum.

Expand Down Expand Up @@ -133,4 +133,4 @@ The example above can be split into two scripts to work:
- A script in an external file can be inserted with `<script src="path/to/script.js"></script>`.
There is much more about browser scripts and their interaction with the web-page. But let's keep in mind that this part of the tutorial is devoted to Javascript language. So we shouldn't distract ourselves from it. We'll be using a browser as a way to run Javascript, very convenient for online reading, but yet one of many.
There is much more about browser scripts and their interaction with the web-page. But let's keep in mind that this part of the tutorial is devoted to JavaScript language. So we shouldn't distract ourselves from it. We'll be using a browser as a way to run JavaScript, very convenient for online reading, but yet one of many.
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/05-types/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ We'll see more into working with numbers in the chapter <info:number>.

## A string

A string in Javascript must be quoted.
A string in JavaScript must be quoted.

```js
let str = "Hello";
Expand All @@ -80,7 +80,7 @@ In JavaScript, there are 3 types of quotes.
2. Single quotes: `'Hello'`.
3. Backticks: <code>&#96;Hello&#96;</code>.

Double and single quotes are "simple" quotes. They mark the beginning and the end of the string, that's all. There's no difference between them in Javascript.
Double and single quotes are "simple" quotes. They mark the beginning and the end of the string, that's all. There's no difference between them in JavaScript.

Backticks are "extended functionality" quotes. They allow to embed variables and expressions into a string by wrapping them in `${…}`, for example:

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/06-type-conversions/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ Most of these rules are easy to understand and memorize. The notable exceptions
- `undefined` is `NaN` as a number.
- `"0"` is true as a boolean.
Objects are not covered here, we'll return to them later in the chapter <info:object-toprimitive>, devoted exclusively to objects, after we learn more basic things about Javascript.
Objects are not covered here, we'll return to them later in the chapter <info:object-toprimitive>, devoted exclusively to objects, after we learn more basic things about JavaScript.
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/07-operators/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Before we move on, let's grasp the common terminology.
## Strings concatenation, binary +
Now let's see special features of Javascript operators, beyond school arithmetics.
Now let's see special features of JavaScript operators, beyond school arithmetics.

Usually the plus operator `'+'` sums numbers.

Expand Down
2 changes: 1 addition & 1 deletion 1-js/02-first-steps/09-uibasic/article.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Interaction: alert, prompt, confirm

This part of the tutorial aims to cover Javascript "as is", without environment-specific tweaks.
This part of the tutorial aims to cover JavaScript "as is", without environment-specific tweaks.

But still we use a browser as the demo environment. So we should know at least few user-interface functions.

Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/14-function-basics/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function showMessage(from, text = anotherFunction()) {
````smart header="Default parameters old-style"
Old editions of Javascript did not support default parameters. So there are alternative ways to support them, that you can find mostly in the old scripts.
Old editions of JavaScript did not support default parameters. So there are alternative ways to support them, that you can find mostly in the old scripts.
For instance, an explicit check for being `undefined`:
Expand Down Expand Up @@ -322,7 +322,7 @@ For long expressions, it may be tempting sometimes to put them on a separate lin
return
(some + long + expression + or + whatever * f(a) + f(b))
```
That doesn't work, because Javascript assumes a semicolon after `return` in that case:
That doesn't work, because JavaScript assumes a semicolon after `return` in that case:
```js
return*!*;*/!*
Expand Down
4 changes: 2 additions & 2 deletions 1-js/02-first-steps/15-function-expressions-arrows/article.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Function expressions and arrows

In Javascript a function is not a "magical language structure", but a special kind of value.
In JavaScript a function is not a "magical language structure", but a special kind of value.

The syntax that we used before is called *Function Declaration*:

Expand Down Expand Up @@ -159,7 +159,7 @@ ask(

Here functions are declared right inside the `ask(...)` call. They have no name, and so are called *anonymous*. Such functions are not accessible outside of `ask`, but that's just what we want here.

Such code appears in our scripts very naturally, it's in the spirit of Javascript.
Such code appears in our scripts very naturally, it's in the spirit of JavaScript.


```smart header="A function is a value representing an \"action\""
Expand Down
8 changes: 4 additions & 4 deletions 1-js/02-first-steps/16-javascript-specials/article.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Javascript specials
# JavaScript specials

This chapter aims to list features of JavaScript that we've learned, paying special attention to subtle moments.

Expand Down Expand Up @@ -233,7 +233,7 @@ Details in: <info:switch>.

## Functions

We covered 3 ways to create a function in Javascript:
We covered 3 ways to create a function in JavaScript:

1. Function Declaration: the function in the main code flow

Expand Down Expand Up @@ -291,6 +291,6 @@ More: see <info:function-basics>, <info:function-expressions-arrows>.
## More to come
That was a brief list of Javascript specials that we need to know to code well.
That was a brief list of JavaScript specials that we need to know to code well.
As of now that were only basics. Further in the tutorial you'll find more specials and advanced features of Javascript.
As of now that were only basics. Further in the tutorial you'll find more specials and advanced features of JavaScript.
4 changes: 2 additions & 2 deletions 1-js/03-code-quality/01-debugging-chrome/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Should look like this:

![](chrome-sources-breakpoint.png)

A *breakpoint* is a point of code where the debugger will automatically pause the Javascript execution.
A *breakpoint* is a point of code where the debugger will automatically pause the JavaScript execution.

While the code is paused, we can examine current variables, execute commands in the console etc. That is -- debug it.

Expand Down Expand Up @@ -128,7 +128,7 @@ There are buttons for it at the right-top:
The execution has resumed, reached another breakpoint inside `say()` and paused there. Take a look at the "Call stack" at the right. It has increased by one more call. We're inside `say()` now.

<span class="devtools" style="background-position:-137px -76px"></span> -- make a step (run the next command), but *not go into the function*, hotkey `key:F10`.
: If we click it now, `alert` will be shown. The important thing is that if `alert` were not native, but a Javascript function, then the execution would "step over it", skipping the function internals.
: If we click it now, `alert` will be shown. The important thing is that if `alert` were not native, but a JavaScript function, then the execution would "step over it", skipping the function internals.

<span class="devtools" style="background-position:-72px -76px"></span> -- make a step, hotkey `key:F11`.
: The same as the previous one, but "steps in" nested functions. Clicking this will step through all script actions one by one.
Expand Down
4 changes: 2 additions & 2 deletions 1-js/03-code-quality/02-coding-style/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ There are many open style guides, so there we could just accept the one we like

There exist more there in the wild.

As you become more mature in Javascript programming, you might want to read them all to pick up the common principles.
As you become more mature in JavaScript programming, you might want to read them all to pick up the common principles.

## Style checkers

Expand All @@ -280,7 +280,7 @@ Here are simple steps to start using it:

1. Install [Node.JS](https://nodejs.org/), necessary to run them.
2. Install eslint: `npm i -g eslint` (npm is Node.JS package installer).
3. Create a config file `.eslintrc` in your Javascript project (the dot at the start is mandatory).
3. Create a config file `.eslintrc` in your JavaScript project (the dot at the start is mandatory).

An example of `.eslintrc`:

Expand Down
2 changes: 1 addition & 1 deletion 1-js/03-code-quality/03-comments/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ For instance, for ESLint you should do the following:

1. Install Node.JS (can take from the <http://nodejs.org>).
2. Install ESLint with the command `npm install -g eslint`.
3. Create a config file named `.eslintrc` in the root of your Javascript project (in the folder that contains all your files).
3. Create a config file named `.eslintrc` in the root of your JavaScript project (in the folder that contains all your files).

Here's an example of `.eslintrc`:

Expand Down
6 changes: 3 additions & 3 deletions 1-js/03-code-quality/05-testing/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Enough words. Let's see the example.

Let's say we want to make a function `pow(x, n)` that raises `x` to an integer power `n`. We assume that `n≥0`.

That task is quite simple, there's even a `**` operator in Javascript that can do that, but here we concentrate not on the function itself, but on the development flow, that can be applied to more complex tasks as well.
That task is quite simple, there's even a `**` operator in JavaScript that can do that, but here we concentrate not on the function itself, but on the development flow, that can be applied to more complex tasks as well.

Before creating the code of `pow`, we can imagine what the function should do and describe it using BDD.

Expand Down Expand Up @@ -304,7 +304,7 @@ The basic functionality of `pow` is complete. The first iteration of the develop
As it was said, the function `pow(x, n)` is meant to work with positive integer values `n`.
To indicate a mathematical error, Javascript functions usually return `NaN`. Let's do the same for invalid values of `n`.
To indicate a mathematical error, JavaScript functions usually return `NaN`. Let's do the same for invalid values of `n`.
Let's first add the behavior to the spec(!):
Expand Down Expand Up @@ -408,4 +408,4 @@ In real life that's sometimes not that easy. Sometimes it's difficult to write a
Later in the tutorial you will meet many tasks with tests baked-in. So you will more practical examples.
Writing tests requires good Javascript knowledge. But we're just starting to learn it. So, to settle down everything, as of now you're not required to write tests, but you should already be able to read them even if they are a little bit more complex than in this chapter.
Writing tests requires good JavaScript knowledge. But we're just starting to learn it. So, to settle down everything, as of now you're not required to write tests, but you should already be able to read them even if they are a little bit more complex than in this chapter.
10 changes: 5 additions & 5 deletions 1-js/04-object-basics/01-object/article.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

# Objects

As we know, there are 7 language types in Javascript. Six of them are called "primitive", because their values contain only a single thing (be it a string or a number or whatever).
As we know, there are 7 language types in JavaScript. Six of them are called "primitive", because their values contain only a single thing (be it a string or a number or whatever).

In contrast, objects are used to store keyed collections of various data and more complex entities. In Javascript, objects penetrate almost every aspect of the language. So we must understand them first before going in-depth anywhere else.
In contrast, objects are used to store keyed collections of various data and more complex entities. In JavaScript, objects penetrate almost every aspect of the language. So we must understand them first before going in-depth anywhere else.

[cut]

Expand Down Expand Up @@ -544,7 +544,7 @@ So, copying an object variable creates one more reference to the same object.
But what if we need to duplicate an object? Create an independant copy, a clone?
That's also doable, but a little bit more difficult, because there's no built-in method for that in Javascript. Actually, that's rarely needed, copying by reference is good most of the time.
That's also doable, but a little bit more difficult, because there's no built-in method for that in JavaScript. Actually, that's rarely needed, copying by reference is good most of the time.
But if we really want that, then we need to create a new object and replicate the structure of the existing one by iterating over its properties and copying them on the primitive level.
Expand Down Expand Up @@ -661,7 +661,7 @@ alert(clone.sizes.width); // 51, see the result from the other one
To fix that, we should use the cloning loop that examines each value of `user[key]` and, if it's an object, then replicate it's structure as well. That is called a "deep cloning".
There's a standard algorithm for deep cloning that handles the case above and more complex cases, called the [Structured cloning algorithm](w3c.github.io/html/infrastructure.html#internal-structured-cloning-algorithm). Not to reinvent the wheel, we can use a working implementation of it from the Javascript library [lodash](https://lodash.com), the method is called [_.cloneDeep(obj)](https://lodash.com/docs#cloneDeep).
There's a standard algorithm for deep cloning that handles the case above and more complex cases, called the [Structured cloning algorithm](w3c.github.io/html/infrastructure.html#internal-structured-cloning-algorithm). Not to reinvent the wheel, we can use a working implementation of it from the JavaScript library [lodash](https://lodash.com), the method is called [_.cloneDeep(obj)](https://lodash.com/docs#cloneDeep).
Expand All @@ -688,7 +688,7 @@ To make a "real copy" (a clone) we can use `Object.assign` or [_.cloneDeep(obj)
What we've studied in this chapter is called a "plain object", or just `Object`.
There are many other kinds of objects in Javascript:
There are many other kinds of objects in JavaScript:
- `Array` to store ordered data collections,
- `Date` to store the information about the date and time,
Expand Down
10 changes: 5 additions & 5 deletions 1-js/04-object-basics/02-garbage-collection/article.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Garbage collection

Memory management in Javascript is performed automatically and invisibly to us. We create primitives, objects, functions... All that takes memory.
Memory management in JavaScript is performed automatically and invisibly to us. We create primitives, objects, functions... All that takes memory.

What happens when something is not needed any more? How Javascript engine discovers that and cleans up?
What happens when something is not needed any more? How JavaScript engine discovers that and cleans up?

[cut]

## Reachability

The main concept of memory management in Javascript is *reachability*.
The main concept of memory management in JavaScript is *reachability*.

Simply put, "reachable" values are those that are accessible or useable somehow. They are guaranteed to be stored in memory.

Expand All @@ -27,7 +27,7 @@ Simply put, "reachable" values are those that are accessible or useable somehow.

For instance, if there's an object in a local variable, and that object has a property referencing another object, that object is considered reachable. And those that it references -- are also reachable. Detailed examples to follow.

There's a background process in the Javascript engine that is called [garbage collector](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)). It monitors all objects and removes those that became unreachable.
There's a background process in the JavaScript engine that is called [garbage collector](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)). It monitors all objects and removes those that became unreachable.

## A simple example

Expand Down Expand Up @@ -185,7 +185,7 @@ Now the objects that could not be visited in the process are considered unreacha

That's the concept how garbage collection works.

Javascript engines apply many optimizations to make it run faster and not affect the execution.
JavaScript engines apply many optimizations to make it run faster and not affect the execution.

Some of the optimizations:

Expand Down
10 changes: 5 additions & 5 deletions 1-js/04-object-basics/03-symbol/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ alert(id1 == id2); // false
*/!*
```

If you are familiar with Ruby or another language that also has some sort of "symbols" -- please don't be misguided. Javascript symbols are different.
If you are familiar with Ruby or another language that also has some sort of "symbols" -- please don't be misguided. JavaScript symbols are different.


## "Hidden" properties
Expand All @@ -48,7 +48,7 @@ user[id] = "ID Value";
alert( user[id] ); // we can access the data using the symbol as the key
```

Now let's imagine that another script wants to have his own "id" property inside `user`, for his own purposes. That may be another Javascript library, so the scripts are completely unaware for each other.
Now let's imagine that another script wants to have his own "id" property inside `user`, for his own purposes. That may be another JavaScript library, so the scripts are completely unaware for each other.

No problem. It can create its own `Symbol("id")`.

Expand Down Expand Up @@ -178,7 +178,7 @@ Symbols inside the registry are called *global symbols*. If we want an applicati
```smart header="That sounds like Ruby"
In some programming languages, like Ruby, there's a single symbol per name.
In Javascript, as we can see, that's right for global symbols.
In JavaScript, as we can see, that's right for global symbols.
```

### Symbol.keyFor
Expand Down Expand Up @@ -210,7 +210,7 @@ For non-global symbols, the name is only used for debugging purposes.

## System symbols

There exist many "system" symbols that Javascript uses internally, and we can use them to fine-tune various aspects of our objects.
There exist many "system" symbols that JavaScript uses internally, and we can use them to fine-tune various aspects of our objects.

They are listed in the specification in the [Well-known symbols](https://tc39.github.io/ecma262/#sec-well-known-symbols) table:

Expand All @@ -231,7 +231,7 @@ Other symbols will also become familiar when we study the corresponding language
- Symbols are useful if we want to create a field that only those who know the symbol can access.
- Symbols don't appear in `for..in` loops.
- Symbols created with `Symbol(name)` are always different, even if they have the same name. If we want same-named symbols to be equal, then we should use the global registry: `Symbol.for(name)` returns (creates if needed) a global symbol with the given name. Multiple calls return the same symbol.
- There are system symbols used by Javascript and accessible as `Symbol.*`. We can use them to alter some built-in behaviors.
- There are system symbols used by JavaScript and accessible as `Symbol.*`. We can use them to alter some built-in behaviors.

Technically, symbols are not 100% hidden. There is a build-in method [Object.getOwnPropertySymbols(obj)](mdn:js/Object/getOwnPropertySymbols) that allows to get all symbols. Also there is a method named [Reflect.ownKeys(obj)](mdn:js/Reflect/ownKeys) that returns *all* keys of an object including symbolic ones. So they are not really hidden.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The error message in most browsers does not give understanding what went wrong.

**The error appears because a semicolon is missing after `user = {...}`.**

Javascript does not assume a semicolon before a bracket `(user.go)()`, so it reads the code like:
JavaScript does not assume a semicolon before a bracket `(user.go)()`, so it reads the code like:

```js no-beautify
let user = { go:... }(user.go)()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Modify the code of `up` and `down` to make the calls chainable, like this:
ladder.up().up().down().showStep(); // 1
```

Such approach is widely used across Javascript libraries.
Such approach is widely used across JavaScript libraries.
Loading

0 comments on commit 75e3053

Please sign in to comment.