Skip to content

Commit 3451b31

Browse files
committed
pre-move-destruct
1 parent 506e517 commit 3451b31

2 files changed

Lines changed: 16 additions & 22 deletions

File tree

1-js/2-first-steps/07-types/article.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@ All other types are called "primitive", because their values can contain only a
176176

177177
In contrast, objects are used to store *keyed collections* of various data and more complex entities. In programming that's sometimes called an "associative array" or a "hash".
178178

179-
An object is defined with the figure brackets `{…}` with an optional list of *properties*. A property is a "key: value" pairs, where `key` is a string (also called a "property name"), and `value` can be anything.
179+
An object is defined with the figure brackets `{…}` with an optional list of *properties*. A property is a "key: value" pair, where `key` is a string (also called a "property name"), and `value` can be anything.
180180

181-
For instance, here we create a `user` object with two properties:
181+
For instance, here we create an object `user` with two properties:
182182

183183
```js
184-
let user = { // an object
184+
let user = {
185185
name: "John", // key "name", value "John"
186186
age: 30 // key "age", value 30
187187
};
@@ -207,23 +207,23 @@ user.isAdmin = true;
207207

208208
![user object 2](object-user-isadmin.png)
209209

210-
...Or remove it with the help of `delete` operator:
210+
...Or remove the `age` property with the help of `delete` operator:
211211

212212
```js
213213
delete user.age;
214214
```
215215

216216
![user object 3](object-user-delete.png)
217217

218-
Technically, the key may be any string, even with multiple words, for instance `"hello world"`, or even a sentence like `"likes to swim?"`.
218+
Technically, we can name the property using any string, like `"hello world"`, or even a sentence like `"likes to swim?"`. And sometimes that's handy.
219219

220-
To work with such keys, there exists another way to access them, because the dot notation doesn't work:
220+
But to work with complex keys, there's another way to access them, because the dot notation stops working:
221221

222222
```js run
223223
user.likes to swim? = true; // syntax error!
224224
```
225225
226-
The dot assumes that the key is a valid variable identifier (no spaces and other limitations).
226+
That's because the dot only supports keys that are valid variable identifiers (no spaces and other limitations).
227227
228228
There's a more powerful "square bracket notation" that works with any string:
229229
@@ -240,9 +240,9 @@ alert(user["likes to swim?"]); // true
240240
delete user["likes to swim?"];
241241
```
242242
243-
Now everything is fine. Please note that the string must be properly quoted (any type of quotes will do).
243+
Now everything is fine. Please note that the string is properly quoted (any type of quotes will do).
244244
245-
Square brackets are also the way to access a property by the name from the variable:
245+
Square brackets are also provide a way to access a property by the name from the variable:
246246
247247
```js
248248
let key = "likes to swim?";
@@ -251,7 +251,7 @@ let key = "likes to swim?";
251251
user[key] = true;
252252
```
253253
254-
Here, the variable `key` is probably evaluated or calculated at run-time. And then we use it to access the property. That gives us a great deal of flexibility. The dot notation cannot be used the similar way.
254+
Here, the variable `key` is may be evaluated or calculated at run-time. And then we use it to access the property. That gives us a great deal of flexibility. The dot notation cannot be used in similar way.
255255
256256
So, most of time, the dot notation is used to access known and simple object properties, but when we need something more complex, then we use square brackets.
257257
@@ -268,15 +268,15 @@ They serve as a basis for many other, more specialized kinds of objects:
268268
269269
These more advanced objects do not have types of their own, but belong to a single "object" data type. And they extend it in various ways. Of course we'll see how they do it.
270270
271-
Objects in JavaScript are very powerful. Here we've just started to get the basics of the topic that is really huge. Now we can create plain objects and add/remove properties from them. But we'll be closely working with objects and learning more about them in further parts of the tutorial.
271+
Objects in JavaScript are very powerful. Here we've just started to get the basics of the topic that is really huge. Now we can create plain objects and add/remove properties from them. But we'll be consistently returning to objects and learn much more about them in further parts of the tutorial.
272272
273273
## Arrays
274274
275275
As we’ve just seen, objects in Javascript store arbitrary keyed values.
276276
277277
But quite often we find that we need an *ordered collection*, where we have a 1st, a 2nd, a 3rd element and so on.
278278
279-
For example, we need that to store a list of something: users, goods, HTML elements etc. Plain objects do not provide ways to set the order of elements. We can't directly access the n-th element in an object by its number. Also we can’t insert a new property between the existing ones. Objects are just not meant for such use.
279+
For example, we need that to store a list of something: users, goods, HTML elements etc. Plain objects do not provide ways to set the order of elements. We can't directly access the n-th property of an object by its number. Also we can’t insert a new property "between" the existing ones. Objects are just not meant for such use.
280280
281281
There exists a special data structure named "an array", to store ordered collections.
282282
@@ -318,7 +318,7 @@ A value of this type can be created using `Symbol(name)`:
318318
let id = Symbol("id");
319319
```
320320
321-
If you used Ruby language (or few others that have symbols too), then you may have heard a thing or two about symbols already. But stay tuned. Symbols in JavaScript are different. Please don't get trapped by the same word.
321+
If you used Ruby language (or few others that have symbols too), then you may feel proficient about symbols already. But stay tuned. Symbols in JavaScript are different. Please don't get trapped by the same word.
322322
323323
`Symbol` is a special primitive type used for identifiers, which are guaranteed to be unique. So, even if we create many symbols with the same name, they are still unique, and not equal:
324324
@@ -327,7 +327,7 @@ let id1 = Symbol("id");
327327
let id2 = Symbol("id");
328328

329329
*!*
330-
alert(id1 == id2); // false
330+
alert(id1 == id2); // false (!)
331331
*/!*
332332
```
333333
@@ -347,7 +347,7 @@ user.id = 123;
347347
alert( user.id ); // 123
348348
```
349349
350-
Now let's imagine that another script wants to work with that object, and it also would like to store an identifier in the object, for its own purposes. The script is written by another person, so the scripts are completely unaware for each other.
350+
Now let's imagine that another script wants to work with that object, and it also would like to store an identifier in the object, for its own purposes. The script is written by *another person*, so the scripts are completely unaware for each other.
351351
352352
...But if it tries to make use of the same `"id"` key, then it would occasionally overwrite our id. That's the conflict.
353353

1-js/2-first-steps/12-uibasic/article.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,7 @@ It shows a modal window with the given `title`, a field for text, initially fill
3636

3737
The visitor may type something in the field and press OK. Or he can cancel the input by pressing a CANCEL button or the `key:Esc` key.
3838

39-
The call to `prompt` returns the text from the field or `null` if te input is canceled.
40-
41-
```warn header="Safari does not return `null`"
42-
Safari returns an empty string instead of `null` on cancellation. So we can't be sure whether the user actually entered an empty line or he cancelled the input.
43-
44-
A compatible practice is to treat both an empty line and `null` the same, as a cancellation.
45-
```
39+
The call to `prompt` returns the text from the field or `null` if the input is canceled.
4640

4741
As with `alert`, the `prompt` window is modal.
4842

0 commit comments

Comments
 (0)