You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/01-hello-world/article.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Hello, world!
2
2
3
-
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.
3
+
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.
4
4
5
5
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.
6
6
@@ -133,4 +133,4 @@ The example above can be split into two scripts to work:
133
133
- A script in an external file can be inserted with `<script src="path/to/script.js"></script>`.
134
134
135
135
136
-
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.
136
+
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.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/05-types/article.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,7 @@ We'll see more into working with numbers in the chapter <info:number>.
66
66
67
67
## A string
68
68
69
-
A string in Javascript must be quoted.
69
+
A string in JavaScript must be quoted.
70
70
71
71
```js
72
72
let str ="Hello";
@@ -80,7 +80,7 @@ In JavaScript, there are 3 types of quotes.
80
80
2. Single quotes: `'Hello'`.
81
81
3. Backticks: <code>`Hello`</code>.
82
82
83
-
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.
83
+
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.
84
84
85
85
Backticks are "extended functionality" quotes. They allow to embed variables and expressions into a string by wrapping them in `${…}`, for example:
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/06-type-conversions/article.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -167,4 +167,4 @@ Most of these rules are easy to understand and memorize. The notable exceptions
167
167
- `undefined` is `NaN` as a number.
168
168
- `"0"` is true as a boolean.
169
169
170
-
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.
170
+
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.
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/14-function-basics/article.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -207,7 +207,7 @@ function showMessage(from, text = anotherFunction()) {
207
207
208
208
209
209
````smart header="Default parameters old-style"
210
-
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.
210
+
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.
211
211
212
212
For instance, an explicit check for being `undefined`:
213
213
@@ -322,7 +322,7 @@ For long expressions, it may be tempting sometimes to put them on a separate lin
322
322
return
323
323
(some + long + expression + or + whatever *f(a) +f(b))
324
324
```
325
-
That doesn't work, because Javascript assumes a semicolon after `return` in that case:
325
+
That doesn't work, because JavaScript assumes a semicolon after `return` in that case:
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/15-function-expressions-arrows/article.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Function expressions and arrows
2
2
3
-
In Javascript a function is not a "magical language structure", but a special kind of value.
3
+
In JavaScript a function is not a "magical language structure", but a special kind of value.
4
4
5
5
The syntax that we used before is called *Function Declaration*:
6
6
@@ -159,7 +159,7 @@ ask(
159
159
160
160
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.
161
161
162
-
Such code appears in our scripts very naturally, it's in the spirit of Javascript.
162
+
Such code appears in our scripts very naturally, it's in the spirit of JavaScript.
163
163
164
164
165
165
```smart header="A function is a value representing an \"action\""
Copy file name to clipboardExpand all lines: 1-js/03-code-quality/01-debugging-chrome/article.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ Should look like this:
54
54
55
55

56
56
57
-
A *breakpoint* is a point of code where the debugger will automatically pause the Javascript execution.
57
+
A *breakpoint* is a point of code where the debugger will automatically pause the JavaScript execution.
58
58
59
59
While the code is paused, we can examine current variables, execute commands in the console etc. That is -- debug it.
60
60
@@ -128,7 +128,7 @@ There are buttons for it at the right-top:
128
128
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.
129
129
130
130
<spanclass="devtools"style="background-position:-137px-76px"></span> -- make a step (run the next command), but *not go into the function*, hotkey `key:F10`.
131
-
: 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.
131
+
: 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.
132
132
133
133
<spanclass="devtools"style="background-position:-72px-76px"></span> -- make a step, hotkey `key:F11`.
134
134
: The same as the previous one, but "steps in" nested functions. Clicking this will step through all script actions one by one.
Copy file name to clipboardExpand all lines: 1-js/03-code-quality/05-testing/article.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Enough words. Let's see the example.
36
36
37
37
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`.
38
38
39
-
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.
39
+
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.
40
40
41
41
Before creating the code of `pow`, we can imagine what the function should do and describe it using BDD.
42
42
@@ -304,7 +304,7 @@ The basic functionality of `pow` is complete. The first iteration of the develop
304
304
305
305
As it was said, the function `pow(x, n)` is meant to work with positive integer values `n`.
306
306
307
-
To indicate a mathematical error, Javascript functions usually return `NaN`. Let's do the same for invalid values of `n`.
307
+
To indicate a mathematical error, JavaScript functions usually return `NaN`. Let's do the same for invalid values of `n`.
308
308
309
309
Let's first add the behavior to the spec(!):
310
310
@@ -408,4 +408,4 @@ In real life that's sometimes not that easy. Sometimes it's difficult to write a
408
408
409
409
Later in the tutorial you will meet many tasks with tests baked-in. So you will more practical examples.
410
410
411
-
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.
411
+
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.
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/01-object/article.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
2
2
# Objects
3
3
4
-
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).
4
+
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).
5
5
6
-
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.
6
+
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.
7
7
8
8
[cut]
9
9
@@ -544,7 +544,7 @@ So, copying an object variable creates one more reference to the same object.
544
544
545
545
But what if we need to duplicate an object? Create an independant copy, a clone?
546
546
547
-
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.
547
+
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.
548
548
549
549
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.
550
550
@@ -661,7 +661,7 @@ alert(clone.sizes.width); // 51, see the result from the other one
661
661
662
662
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".
663
663
664
-
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).
664
+
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).
665
665
666
666
667
667
@@ -688,7 +688,7 @@ To make a "real copy" (a clone) we can use `Object.assign` or [_.cloneDeep(obj)
688
688
689
689
What we've studied in this chapter is called a "plain object", or just `Object`.
690
690
691
-
There are many other kinds of objects in Javascript:
691
+
There are many other kinds of objects in JavaScript:
692
692
693
693
- `Array` to store ordered data collections,
694
694
- `Date` to store the information about the date and time,
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/02-garbage-collection/article.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,14 @@
1
1
# Garbage collection
2
2
3
-
Memory management in Javascript is performed automatically and invisibly to us. We create primitives, objects, functions... All that takes memory.
3
+
Memory management in JavaScript is performed automatically and invisibly to us. We create primitives, objects, functions... All that takes memory.
4
4
5
-
What happens when something is not needed any more? How Javascript engine discovers that and cleans up?
5
+
What happens when something is not needed any more? How JavaScript engine discovers that and cleans up?
6
6
7
7
[cut]
8
8
9
9
## Reachability
10
10
11
-
The main concept of memory management in Javascript is *reachability*.
11
+
The main concept of memory management in JavaScript is *reachability*.
12
12
13
13
Simply put, "reachable" values are those that are accessible or useable somehow. They are guaranteed to be stored in memory.
14
14
@@ -27,7 +27,7 @@ Simply put, "reachable" values are those that are accessible or useable somehow.
27
27
28
28
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.
29
29
30
-
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.
30
+
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.
31
31
32
32
## A simple example
33
33
@@ -185,7 +185,7 @@ Now the objects that could not be visited in the process are considered unreacha
185
185
186
186
That's the concept how garbage collection works.
187
187
188
-
Javascript engines apply many optimizations to make it run faster and not affect the execution.
188
+
JavaScript engines apply many optimizations to make it run faster and not affect the execution.
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/03-symbol/article.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ alert(id1 == id2); // false
31
31
*/!*
32
32
```
33
33
34
-
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.
34
+
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.
35
35
36
36
37
37
## "Hidden" properties
@@ -48,7 +48,7 @@ user[id] = "ID Value";
48
48
alert( user[id] ); // we can access the data using the symbol as the key
49
49
```
50
50
51
-
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.
51
+
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.
52
52
53
53
No problem. It can create its own `Symbol("id")`.
54
54
@@ -178,7 +178,7 @@ Symbols inside the registry are called *global symbols*. If we want an applicati
178
178
```smart header="That sounds like Ruby"
179
179
In some programming languages, like Ruby, there's a single symbol per name.
180
180
181
-
In Javascript, as we can see, that's right for global symbols.
181
+
In JavaScript, as we can see, that's right for global symbols.
182
182
```
183
183
184
184
### Symbol.keyFor
@@ -210,7 +210,7 @@ For non-global symbols, the name is only used for debugging purposes.
210
210
211
211
## System symbols
212
212
213
-
There exist many "system" symbols that Javascript uses internally, and we can use them to fine-tune various aspects of our objects.
213
+
There exist many "system" symbols that JavaScript uses internally, and we can use them to fine-tune various aspects of our objects.
214
214
215
215
They are listed in the specification in the [Well-known symbols](https://tc39.github.io/ecma262/#sec-well-known-symbols) table:
216
216
@@ -231,7 +231,7 @@ Other symbols will also become familiar when we study the corresponding language
231
231
- Symbols are useful if we want to create a field that only those who know the symbol can access.
232
232
- Symbols don't appear in `for..in` loops.
233
233
- 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.
234
-
- There are system symbols used by Javascript and accessible as `Symbol.*`. We can use them to alter some built-in behaviors.
234
+
- There are system symbols used by JavaScript and accessible as `Symbol.*`. We can use them to alter some built-in behaviors.
235
235
236
236
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.
0 commit comments